fixed editor zooming if gui is not active
[twcon.git] / datasrc / network.py
blobcd5f5aee99d26e6975d8c518929cc1e4a2ced72c
1 from datatypes import *
3 Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
4 PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD"]
5 GameFlags = ["TEAMS", "FLAGS"]
6 GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED"]
8 Emoticons = ["OOP", "EXCLAMATION", "HEARTS", "DROP", "DOTDOT", "MUSIC", "SORRY", "GHOST", "SUSHI", "SPLATTEE", "DEVILTEE", "ZOMG", "ZZZ", "WTF", "EYES", "QUESTION"]
10 Powerups = ["HEALTH", "ARMOR", "WEAPON", "NINJA"]
12 RawHeader = '''
14 #include <engine/message.h>
16 enum
18 INPUT_STATE_MASK=0x3f
21 enum
23 TEAM_SPECTATORS=-1,
24 TEAM_RED,
25 TEAM_BLUE,
27 FLAG_MISSING=-3,
28 FLAG_ATSTAND,
29 FLAG_TAKEN,
31 SPEC_FREEVIEW=-1,
33 '''
35 RawSource = '''
36 #include <engine/message.h>
37 #include "protocol.h"
38 '''
40 Enums = [
41 Enum("EMOTE", Emotes),
42 Enum("POWERUP", Powerups),
43 Enum("EMOTICON", Emoticons)
46 Flags = [
47 Flags("PLAYERFLAG", PlayerFlags),
48 Flags("GAMEFLAG", GameFlags),
49 Flags("GAMESTATEFLAG", GameStateFlags)
52 Objects = [
54 NetObject("PlayerInput", [
55 NetIntAny("m_Direction"),
56 NetIntAny("m_TargetX"),
57 NetIntAny("m_TargetY"),
59 NetIntAny("m_Jump"),
60 NetIntAny("m_Fire"),
61 NetIntAny("m_Hook"),
63 NetIntRange("m_PlayerFlags", 0, 256),
65 NetIntAny("m_WantedWeapon"),
66 NetIntAny("m_NextWeapon"),
67 NetIntAny("m_PrevWeapon"),
68 ]),
70 NetObject("Projectile", [
71 NetIntAny("m_X"),
72 NetIntAny("m_Y"),
73 NetIntAny("m_VelX"),
74 NetIntAny("m_VelY"),
76 NetIntRange("m_Type", 0, 'NUM_WEAPONS-1'),
77 NetTick("m_StartTick"),
78 ]),
80 NetObject("Laser", [
81 NetIntAny("m_X"),
82 NetIntAny("m_Y"),
83 NetIntAny("m_FromX"),
84 NetIntAny("m_FromY"),
86 NetTick("m_StartTick"),
87 ]),
89 NetObject("Pickup", [
90 NetIntAny("m_X"),
91 NetIntAny("m_Y"),
93 NetIntRange("m_Type", 0, 'max_int'),
94 NetIntRange("m_Subtype", 0, 'max_int'),
95 ]),
97 NetObject("Flag", [
98 NetIntAny("m_X"),
99 NetIntAny("m_Y"),
101 NetIntRange("m_Team", 'TEAM_RED', 'TEAM_BLUE')
104 NetObject("GameInfo", [
105 NetIntRange("m_GameFlags", 0, 256),
106 NetIntRange("m_GameStateFlags", 0, 256),
107 NetTick("m_RoundStartTick"),
108 NetIntRange("m_WarmupTimer", 0, 'max_int'),
110 NetIntRange("m_ScoreLimit", 0, 'max_int'),
111 NetIntRange("m_TimeLimit", 0, 'max_int'),
113 NetIntRange("m_RoundNum", 0, 'max_int'),
114 NetIntRange("m_RoundCurrent", 0, 'max_int'),
117 NetObject("GameData", [
118 NetIntAny("m_TeamscoreRed"),
119 NetIntAny("m_TeamscoreBlue"),
121 NetIntRange("m_FlagCarrierRed", 'FLAG_MISSING', 'MAX_CLIENTS-1'),
122 NetIntRange("m_FlagCarrierBlue", 'FLAG_MISSING', 'MAX_CLIENTS-1'),
125 NetObject("CharacterCore", [
126 NetIntAny("m_Tick"),
127 NetIntAny("m_X"),
128 NetIntAny("m_Y"),
129 NetIntAny("m_VelX"),
130 NetIntAny("m_VelY"),
132 NetIntAny("m_Angle"),
133 NetIntRange("m_Direction", -1, 1),
135 NetIntRange("m_Jumped", 0, 3),
136 NetIntRange("m_HookedPlayer", 0, 'MAX_CLIENTS-1'),
137 NetIntRange("m_HookState", -1, 5),
138 NetTick("m_HookTick"),
140 NetIntAny("m_HookX"),
141 NetIntAny("m_HookY"),
142 NetIntAny("m_HookDx"),
143 NetIntAny("m_HookDy"),
146 NetObject("Character:CharacterCore", [
147 NetIntRange("m_PlayerFlags", 0, 256),
148 NetIntRange("m_Health", 0, 10),
149 NetIntRange("m_Armor", 0, 10),
150 NetIntRange("m_AmmoCount", 0, 10),
151 NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'),
152 NetIntRange("m_Emote", 0, len(Emotes)),
153 NetIntRange("m_AttackTick", 0, 'max_int'),
156 NetObject("PlayerInfo", [
157 NetIntRange("m_Local", 0, 1),
158 NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
159 NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
161 NetIntAny("m_Score"),
162 NetIntAny("m_Latency"),
165 NetObject("ClientInfo", [
166 # 4*4 = 16 charachters
167 NetIntAny("m_Name0"), NetIntAny("m_Name1"), NetIntAny("m_Name2"),
168 NetIntAny("m_Name3"),
170 # 4*3 = 12 charachters
171 NetIntAny("m_Clan0"), NetIntAny("m_Clan1"), NetIntAny("m_Clan2"),
173 NetIntAny("m_Country"),
175 # 4*6 = 24 charachters
176 NetIntAny("m_Skin0"), NetIntAny("m_Skin1"), NetIntAny("m_Skin2"),
177 NetIntAny("m_Skin3"), NetIntAny("m_Skin4"), NetIntAny("m_Skin5"),
179 NetIntRange("m_UseCustomColor", 0, 1),
181 NetIntAny("m_ColorBody"),
182 NetIntAny("m_ColorFeet"),
185 NetObject("SpectatorInfo", [
186 NetIntRange("m_SpectatorID", 'SPEC_FREEVIEW', 'MAX_CLIENTS-1'),
187 NetIntAny("m_X"),
188 NetIntAny("m_Y"),
191 ## Events
193 NetEvent("Common", [
194 NetIntAny("m_X"),
195 NetIntAny("m_Y"),
199 NetEvent("Explosion:Common", []),
200 NetEvent("Spawn:Common", []),
201 NetEvent("HammerHit:Common", []),
203 NetEvent("Death:Common", [
204 NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
207 NetEvent("SoundGlobal:Common", [ #TODO 0.7: remove me
208 NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'),
211 NetEvent("SoundWorld:Common", [
212 NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'),
215 NetEvent("DamageInd:Common", [
216 NetIntAny("m_Angle"),
220 Messages = [
222 ### Server messages
223 NetMessage("Sv_Motd", [
224 NetString("m_pMessage"),
227 NetMessage("Sv_Broadcast", [
228 NetString("m_pMessage"),
231 NetMessage("Sv_Chat", [
232 NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
233 NetIntRange("m_ClientID", -1, 'MAX_CLIENTS-1'),
234 NetString("m_pMessage"),
237 NetMessage("Sv_KillMsg", [
238 NetIntRange("m_Killer", 0, 'MAX_CLIENTS-1'),
239 NetIntRange("m_Victim", 0, 'MAX_CLIENTS-1'),
240 NetIntRange("m_Weapon", -3, 'NUM_WEAPONS-1'),
241 NetIntAny("m_ModeSpecial"),
244 NetMessage("Sv_SoundGlobal", [
245 NetIntRange("m_SoundID", 0, 'NUM_SOUNDS-1'),
248 NetMessage("Sv_TuneParams", []),
249 NetMessage("Sv_ExtraProjectile", []),
250 NetMessage("Sv_ReadyToEnter", []),
252 NetMessage("Sv_WeaponPickup", [
253 NetIntRange("m_Weapon", 0, 'NUM_WEAPONS-1'),
256 NetMessage("Sv_Emoticon", [
257 NetIntRange("m_ClientID", 0, 'MAX_CLIENTS-1'),
258 NetIntRange("m_Emoticon", 0, 'NUM_EMOTICONS-1'),
261 NetMessage("Sv_VoteClearOptions", [
264 NetMessage("Sv_VoteOptionListAdd", [
265 NetIntRange("m_NumOptions", 1, 15),
266 NetStringStrict("m_pDescription0"), NetStringStrict("m_pDescription1"), NetStringStrict("m_pDescription2"),
267 NetStringStrict("m_pDescription3"), NetStringStrict("m_pDescription4"), NetStringStrict("m_pDescription5"),
268 NetStringStrict("m_pDescription6"), NetStringStrict("m_pDescription7"), NetStringStrict("m_pDescription8"),
269 NetStringStrict("m_pDescription9"), NetStringStrict("m_pDescription10"), NetStringStrict("m_pDescription11"),
270 NetStringStrict("m_pDescription12"), NetStringStrict("m_pDescription13"), NetStringStrict("m_pDescription14"),
273 NetMessage("Sv_VoteOptionAdd", [
274 NetStringStrict("m_pDescription"),
277 NetMessage("Sv_VoteOptionRemove", [
278 NetStringStrict("m_pDescription"),
281 NetMessage("Sv_VoteSet", [
282 NetIntRange("m_Timeout", 0, 60),
283 NetStringStrict("m_pDescription"),
284 NetStringStrict("m_pReason"),
287 NetMessage("Sv_VoteStatus", [
288 NetIntRange("m_Yes", 0, 'MAX_CLIENTS'),
289 NetIntRange("m_No", 0, 'MAX_CLIENTS'),
290 NetIntRange("m_Pass", 0, 'MAX_CLIENTS'),
291 NetIntRange("m_Total", 0, 'MAX_CLIENTS'),
294 ### Client messages
295 NetMessage("Cl_Say", [
296 NetBool("m_Team"),
297 NetString("m_pMessage"),
300 NetMessage("Cl_SetTeam", [
301 NetIntRange("m_Team", 'TEAM_SPECTATORS', 'TEAM_BLUE'),
304 NetMessage("Cl_SetSpectatorMode", [
305 NetIntRange("m_SpectatorID", 'SPEC_FREEVIEW', 'MAX_CLIENTS-1'),
308 NetMessage("Cl_StartInfo", [
309 NetStringStrict("m_pName"),
310 NetStringStrict("m_pClan"),
311 NetIntAny("m_Country"),
312 NetStringStrict("m_pSkin"),
313 NetBool("m_UseCustomColor"),
314 NetIntAny("m_ColorBody"),
315 NetIntAny("m_ColorFeet"),
318 NetMessage("Cl_ChangeInfo", [
319 NetStringStrict("m_pName"),
320 NetStringStrict("m_pClan"),
321 NetIntAny("m_Country"),
322 NetStringStrict("m_pSkin"),
323 NetBool("m_UseCustomColor"),
324 NetIntAny("m_ColorBody"),
325 NetIntAny("m_ColorFeet"),
328 NetMessage("Cl_Kill", []),
330 NetMessage("Cl_Emoticon", [
331 NetIntRange("m_Emoticon", 0, 'NUM_EMOTICONS-1'),
334 NetMessage("Cl_Vote", [
335 NetIntRange("m_Vote", -1, 1),
338 NetMessage("Cl_CallVote", [
339 NetStringStrict("m_Type"),
340 NetStringStrict("m_Value"),
341 NetStringStrict("m_Reason"),