Skip to content

Commit 270b635

Browse files
committed
swars: Added get_packet_action_name()
Also renamed few variables. And fixed a bug in PAct_SELECT_AGENT introduced in previous commit.
1 parent 575c930 commit 270b635

File tree

3 files changed

+157
-79
lines changed

3 files changed

+157
-79
lines changed

src/packet.c

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,92 @@ const char *packet_action_result_text[] = {
4747
"thing in bad state",
4848
};
4949

50+
const char *packet_action_name[] = {
51+
"NONE",
52+
"UNKNACTN_01",
53+
"MISSN_ABORT",
54+
"UNKNACTN_03",
55+
"UNKNACTN_04",
56+
"UNKNACTN_05",
57+
"UNKNACTN_06",
58+
"UNKNACTN_07",
59+
"UNKNACTN_08",
60+
"UNKNACTN_09",
61+
"UNKNACTN_0A",
62+
"AGENT_GOTO_GND_PT_ABS",
63+
"AGENT_GOTO_GND_PT_REL",
64+
"SELECT_NEXT_WEAPON",
65+
"DROP_SELC_WEAPON_SECR",
66+
"UNKNACTN_0F",
67+
"PICKUP",
68+
"UNKNACTN_11",
69+
"UNKNACTN_12",
70+
"UNKNACTN_13",
71+
"ENTER_VEHICLE",
72+
"LEAVE_VEHICLE",
73+
"UNKNACTN_16",
74+
"SELECT_AGENT",
75+
"UNKNACTN_18",
76+
"AGENT_GOTO_GND_PT_REL_FF",
77+
"SHOOT_AT_GND_POINT",
78+
"SELECT_PREV_WEAPON",
79+
"PROTECT_INC",
80+
"PROTECT_TOGGLE",
81+
"SHOOT_AT_THING",
82+
"GET_ITEM",
83+
"PLANT_MINE_AT_GND_PT",
84+
"SELECT_SPECIFIC_WEAPON",
85+
"DROP_HELD_WEAPON_SECR",
86+
"AGENT_SET_MOOD",
87+
"GO_ENTER_VEHICLE",
88+
"FOLLOW_PERSON",
89+
"CONTROL_MODE",
90+
"AGENT_GOTO_FACE_PT_ABS",
91+
"AGENT_GOTO_GND_PT_ABS_FF",
92+
"UNKNACTN_29",
93+
"AGENT_GOTO_FACE_PT_ABS_FF",
94+
"GO_ENTER_VEHICLE_FF",
95+
"GET_ITEM_FAST",
96+
"SHIELD_TOGGLE",
97+
"PLANT_MINE_AT_GND_PT_FF",
98+
"SHOOT_AT_GND_POINT_FF",
99+
"PEEPS_SCATTER",
100+
"SELECT_GRP_SPEC_WEAPON",
101+
"AGENT_USE_MEDIKIT",
102+
"UNKNACTN_33",
103+
"GROUP_SET_MOOD",
104+
"AGENT_UNKGROUP_PROT",
105+
"AGENT_UNKGROUP_ADD",
106+
"CHAT_MESSAGE_KEY",
107+
"SHOOT_AT_FACE_POINT",
108+
"SHOOT_AT_FACE_POINT_FF",
109+
"PLANT_MINE_AT_FACE_PT",
110+
"PLANT_MINE_AT_FACE_PT_FF",
111+
"UNKNACTN_3C",
112+
"UNKNACTN_3D",
113+
"UNKNACTN_3E",
114+
"UNKNACTN_3F",
115+
"UNKNACTN_40",
116+
"AGENT_SELF_DESTRUCT",
117+
};
118+
50119
void (*my_build_packet)(struct Packet *packet, ushort type, ulong param1, long x, long y, long z);
51120

52121
/******************************************************************************/
53122

54123
extern TbFileHandle packet_rec_fh;
55124
ushort packet_rec_no = 0;
56125

126+
const char * get_packet_action_name(ushort atype)
127+
{
128+
if (atype > sizeof(packet_action_name)/sizeof(packet_action_name[0]))
129+
return "outranged";
130+
return packet_action_name[atype];
131+
}
132+
57133
const char * get_packet_action_result_text(short result)
58134
{
59-
if ((result < 0) || (result > sizeof(packet_action_result_text)/sizeof(packet_action_result_text[0])))
135+
if ((result < 0) || (result > (int)(sizeof(packet_action_result_text)/sizeof(packet_action_result_text[0]))))
60136
return "outranged";
61137
return packet_action_result_text[result];
62138
}

src/packet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct Packet
146146
extern struct Packet packets[8];
147147
extern void (*my_build_packet)(struct Packet *packet, ushort type, ulong param1, long x, long y, long z);
148148

149+
const char * get_packet_action_name(ushort atype);
149150
const char * get_packet_action_result_text(short result);
150151

151152
void build_packet(struct Packet *packet, ushort type, ulong param1, long x, long y, long z);

0 commit comments

Comments
 (0)