Skip to content

Commit e4517cd

Browse files
committed
Poprawki 2
1 parent 745efe9 commit e4517cd

File tree

6 files changed

+33
-28
lines changed

6 files changed

+33
-28
lines changed

Scenes/GameOver.tscn

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ one_shot = true
5151
anchor_right = 1.0
5252
anchor_bottom = 1.0
5353
texture = ExtResource( 1 )
54+
expand = true
5455
5556
[node name="Label" type="Label" parent="."]
5657
anchor_left = 0.5

Scripts/Enemy.gd

+4-3
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ func server_ai(delta): pass
2727
func general_ai(delta): pass
2828

2929
func hit(body):
30-
if Com.is_server:
31-
if body.is_in_group("player_attack"):
30+
if body.is_in_group("player_attack"):
31+
if body.player:
3232
last_attacker = body.player.get_meta("id")
33-
33+
34+
if Com.is_server:
3435
if has_meta("attackers"):
3536
var id = body.player.get_meta("id")
3637

Scripts/Player.gd

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func process_attack():
235235
get_weapon().set_disabled(false)
236236
attack = true
237237
weapon_point.visible = true
238-
anim.playback_speed = get_weapon().speed + (1 if souls[4] == 15 else 0)
238+
anim.playback_speed = get_weapon().speed + (1 if souls and souls[4] == 15 else 0)
239239
animation = str(get_weapon().attack_type, "Attack", "Crouch" if crouch else "", direction())
240240
anim.play(animation)
241241
elif Controls.SOUL in key_press:

Scripts/UI/LabelManager.gd

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ func on_enemy_attacked(enemy, damage):
1919
else:
2020
enemy.set_meta("hp", enemy.stats.max_hp - damage)
2121

22-
if !enemy.has_meta("label") or !is_instance_valid(enemy.get_meta("label")):
23-
var label = push_label(ENEMY, [enemy.enemy_name, enemy.get_meta("hp"), enemy.stats.max_hp])
24-
enemy.set_meta("label", label)
25-
elif enemy.has_meta("label"):
26-
enemy.get_meta("label").set_bar(enemy.get_meta("hp"), enemy.stats.max_hp)
27-
enemy.get_meta("label").restart()
22+
if enemy.last_attacker == Com.player.get_meta("id"):
23+
if !enemy.has_meta("label") or !is_instance_valid(enemy.get_meta("label")):
24+
var label = push_label(ENEMY, [enemy.enemy_name, enemy.get_meta("hp"), enemy.stats.max_hp])
25+
enemy.set_meta("label", label)
26+
elif enemy.has_meta("label"):
27+
enemy.get_meta("label").set_bar(enemy.get_meta("hp"), enemy.stats.max_hp)
28+
enemy.get_meta("label").restart()
2829

2930
func push_label(type, data):
3031
var label = preload("res://Nodes/UI/InfoLabel.tscn").instance()

Server/Character.cs

+20-10
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,16 @@ public void EquipItem(byte slot, byte from) {
233233

234234
var oldEquip = equipment[slot];
235235

236-
if (from < 255) {
237-
equipment.AsBsonArray[slot] = inventory[from];
238-
inventory.RemoveAt(from);
239-
} else {
240-
equipment.AsBsonArray[slot] = 0;
236+
try {
237+
if (from < 255) {
238+
equipment.AsBsonArray[slot] = inventory[from];
239+
inventory.RemoveAt(from);
240+
} else {
241+
equipment.AsBsonArray[slot] = 0;
242+
}
243+
} catch (ArgumentOutOfRangeException) {
244+
Console.WriteLine("Invalid item index: " + from);
245+
return;
241246
}
242247

243248
if (oldEquip > 0) inventory.Add(oldEquip);
@@ -257,11 +262,16 @@ public void EquipSoul(byte slot, byte from) {
257262

258263
var oldEquip = equipment[slot];
259264

260-
if (from < 255) {
261-
equipment.AsBsonArray[slot] = inventory[from];
262-
inventory.RemoveAt(from);
263-
} else {
264-
equipment.AsBsonArray[slot] = 0;
265+
try {
266+
if (from < 255) {
267+
equipment.AsBsonArray[slot] = inventory[from];
268+
inventory.RemoveAt(from);
269+
} else {
270+
equipment.AsBsonArray[slot] = 0;
271+
}
272+
} catch (ArgumentOutOfRangeException) {
273+
Console.WriteLine("Invalid soul index: " + from);
274+
return;
265275
}
266276

267277
if (oldEquip > 0) inventory.Add(oldEquip);

TODO.txt

-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
-błąd +dodatek >zmiana
22

33
-equip soul nie zawsze dobrze działa
4-
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
5-
Parameter name: index
6-
at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <52405d1838e24bc5b300f5ebeee9f7c4>:0
7-
at MongoDB.Bson.BsonArray.get_Item (System.Int32 index) [0x00000] in <751ae1b3f1ce46e29ca107c13a2209ca>:0
8-
at Character.EquipSoul (System.Byte slot, System.Byte from) [0x00053] in X:\Studia\Magister\the-soulhunter\Server\Character.cs:261
9-
at Unpacker.HandlePacket (Database database, Player player) [0x00344] in X:\Studia\Magister\the-soulhunter\Server\Unpacker.cs:127
10-
at Server.ClientLoop (System.Object _client) [0x0013a] in X:\Studia\Magister\the-soulhunter\Server\Server.cs:120
11-
-nie powinno być labelki wrogów od innyc graczy
124
+zabezpieczenia przed złymi pakietami, wywołaniami metod z niepoprawnymi danymi itp.
135
-żaby mają dałna i skaczą do tyłu
146
+informacje jak ktoś wchodzi albo umiera

0 commit comments

Comments
 (0)