25 |
|
|
26 |
|
#define BETTER_SYNC |
27 |
|
|
28 |
– |
bool FLrServer_PacketCallback(char* data, int datalen, int from) |
29 |
– |
{ |
30 |
– |
int i, j; |
31 |
– |
bool found_player = 0; |
32 |
– |
flatline_packet * packet = (flatline_packet*)data; |
33 |
– |
static int recieved = 0; |
34 |
– |
sockaddr_in sender; |
35 |
– |
sender.sin_family = AF_INET; |
36 |
– |
sender.sin_port = htons(27777); |
37 |
– |
sender.sin_addr = *((struct in_addr*)(int*)&from); |
38 |
– |
|
39 |
– |
|
40 |
– |
//packet->data[datalen] = '\0'; |
41 |
– |
|
42 |
– |
//DDrConsole_PrintF("Packet \r%d recieved from %i", ++recieved, from); |
43 |
– |
|
44 |
– |
|
45 |
– |
|
46 |
– |
//if data[0] != CONNECT_SEND, search in playerlist for ip address |
47 |
– |
|
48 |
– |
|
49 |
– |
|
50 |
– |
|
51 |
– |
switch(packet->id) { |
52 |
– |
flatline_packet connect_recv; |
53 |
– |
player_info * playah; |
54 |
– |
//rewrite this when we get TCP support. |
55 |
– |
//rewrite this before we get TCP support* |
56 |
– |
//the way of seeing if there is room for players sucks. |
57 |
– |
case CONNECT_SEND: |
58 |
– |
; |
59 |
– |
|
60 |
– |
connect_recv.id = CONNECT_REPLY; |
61 |
– |
|
62 |
– |
//if(Players[i].ip == sender.sin_addr.S_un.S_addr) break; //needs to send an error message |
63 |
– |
sender.sin_addr.S_un.S_addr = htonl(sender.sin_addr.S_un.S_addr); |
64 |
– |
playah = FLrServer_AddPlayer(from,packet->connect_send.name, 0, 0); |
65 |
– |
DDrConsole_PrintF("%s connected from %s", packet->connect_send.name, inet_ntoa(sender.sin_addr ) ); |
66 |
– |
if(!((int)playah > -5 && (int)playah <= 0)) { |
67 |
– |
flatline_packet new_char = {0}; |
68 |
– |
CharacterObject* Char; |
69 |
– |
connect_recv.connect_reply.goodtogo = 1; |
70 |
– |
connect_recv.connect_reply.player_slot = playah->list_slot; |
71 |
– |
DDrConsole_PrintF("Slot: %i", playah->list_slot); |
72 |
– |
|
73 |
– |
//sending this several times to make sure it gets through. Really need to make up some form of packet tracking. |
74 |
– |
NetTCPServer_Send((sockaddr *) &sender, (char*)&connect_recv, sizeof(connect_reply) + FLATLINE_HEADER); |
75 |
– |
/* NetTCPServer_Send((sockaddr *) &sender, (char*)&connect_recv, sizeof(connect_reply) + FLATLINE_HEADER); |
76 |
– |
NetTCPServer_Send((sockaddr *) &sender, (char*)&connect_recv, sizeof(connect_reply) + FLATLINE_HEADER); |
77 |
– |
NetTCPServer_Send((sockaddr *) &sender, (char*)&connect_recv, sizeof(connect_reply) + FLATLINE_HEADER); |
78 |
– |
NetTCPServer_Send((sockaddr *) &sender, (char*)&connect_recv, sizeof(connect_reply) + FLATLINE_HEADER); |
79 |
– |
Sleep(100); |
80 |
– |
*/ |
81 |
– |
new_char.id = NEW_PLAYER; |
82 |
– |
Char = &new_char.new_player.Character; |
83 |
– |
memset(Char, 0, sizeof(CharacterObject)); |
84 |
– |
Char->Header.Type = 'CHAR'; |
85 |
– |
Char->OSD.Options = chr_dontaim; |
86 |
– |
for(j = 0; j < max_connections; j++) { |
87 |
– |
if(PlayerList[j] != 0) { |
88 |
– |
new_char.new_player.Playernumber = j; |
89 |
– |
sprintf(Char->OSD.Name,"%s",PlayerList[j]->name); |
90 |
– |
|
91 |
– |
sprintf(Char->OSD.Class, "%s", TMrInstance_GetInstanceName(PlayerList[j]->Chr->ONCC)); |
92 |
– |
DDrConsole_PrintF("Class %s", Char->OSD.Class ); |
93 |
– |
|
94 |
– |
sprintf(Char->OSD.Class, "konoko_generic"); |
95 |
– |
NetTCPServer_Send((sockaddr *) &sender, (char*)&new_char, sizeof(new_player) + FLATLINE_HEADER ); |
96 |
– |
} |
97 |
– |
|
98 |
– |
} |
99 |
– |
} |
100 |
– |
else { |
101 |
– |
//fix the error messages... |
102 |
– |
DDrConsole_PrintF("Server is full. :("); |
103 |
– |
connect_recv.connect_reply.goodtogo = 0; |
104 |
– |
sender.sin_addr.S_un.S_addr = htonl(sender.sin_addr.S_un.S_addr); |
105 |
– |
memcpy(&connect_recv.connect_reply.message,"Server is full.", sizeof("Server is full.")); |
106 |
– |
NetTCPServer_Send((sockaddr *) &sender, (char*)&connect_recv, sizeof(bool)*2 + FLATLINE_HEADER + sizeof("Server is full.")); |
107 |
– |
|
108 |
– |
} |
109 |
– |
|
110 |
– |
|
111 |
– |
break; |
112 |
– |
case CONNECT_REPLY: |
113 |
– |
break; //do nothing...a server shouldn't recieve this type of packet. |
114 |
– |
case MESSAGE: |
115 |
– |
for(i = 0; i < MAX_PLAYERS; i++) { |
116 |
– |
//DDrConsole_PrintF("%i : %i | %s : %s", from, Players[i].ip, inet_ntoa(*(struct in_addr*)&from), inet_ntoa(*(struct in_addr*)&(Players[i].ip))); |
117 |
– |
if(Players[i].ip == sender.sin_addr.S_un.S_addr) { |
118 |
– |
found_player = 1; |
119 |
– |
break; |
120 |
– |
} |
121 |
– |
} |
122 |
– |
if(found_player == 0) return true; |
123 |
– |
else { |
124 |
– |
char message_buffer[512] = {0}; |
125 |
– |
flatline_packet message; |
126 |
– |
int message_size; |
127 |
– |
data[datalen] = 0; |
128 |
– |
|
129 |
– |
DDrConsole_PrintF("%s: %s", Players[i].name, packet->data); |
130 |
– |
sprintf(message_buffer, "%s: %s", Players[i].name, packet->data); |
131 |
– |
|
132 |
– |
message.id = MESSAGE; |
133 |
– |
message_size = sprintf(message.data, "%s", message_buffer); |
134 |
– |
COrMessage_Print(message_buffer, "chat", 0); |
135 |
– |
UDPServer_SendToAll(&message, message_size + 1 + FLATLINE_HEADER); |
136 |
– |
break; |
137 |
– |
} |
138 |
– |
case CHANGE_NAME: |
139 |
– |
; //wtf, needed or i get an error. |
140 |
– |
// DDrConsole_PrintF("Changing Name to: %s", packet->data); |
141 |
– |
for(i = 0; i < MAX_PLAYERS; i++) { |
142 |
– |
if(PlayerList[i] && PlayerList[i]->ip == sender.sin_addr.S_un.S_addr) { |
143 |
– |
found_player = 1; |
144 |
– |
break; |
145 |
– |
} |
146 |
– |
} |
147 |
– |
if(found_player == 0) break; |
148 |
– |
else { |
149 |
– |
bool name_exists = 0; |
150 |
– |
for(j = 0; j < MAX_PLAYERS; j++) { |
151 |
– |
if(PlayerList[j] && !strcmp(packet->data, PlayerList[j]->name)) { |
152 |
– |
name_exists = 1; |
153 |
– |
break; |
154 |
– |
} |
155 |
– |
} |
156 |
– |
if(!name_exists) { |
157 |
– |
FLsUpdateName( i, packet->data ); |
158 |
– |
} |
159 |
– |
break; |
160 |
– |
} |
161 |
– |
case PLAYER_INPUT: |
162 |
– |
|
163 |
– |
for(i = 0; i < max_connections; i++) { |
164 |
– |
if(PlayerList[i] != 0 && PlayerList[i]->ip == sender.sin_addr.S_un.S_addr) { |
165 |
– |
found_player = 1; |
166 |
– |
break; |
167 |
– |
} |
168 |
– |
} |
169 |
– |
|
170 |
– |
if(found_player == 0) break; |
171 |
– |
else { |
172 |
– |
input_struct * packet_input = &packet->input_struct; |
173 |
– |
|
174 |
– |
|
175 |
– |
PlayerList[i]->InputFromClient.Actions1 = packet_input->Actions1; |
176 |
– |
PlayerList[i]->InputFromClient.Actions2 = packet_input->Actions2; |
177 |
– |
PlayerList[i]->InputFromClient.MouseDeltaX = packet_input->MouseDeltaX; |
178 |
– |
PlayerList[i]->InputFromClient.MouseDeltaY = packet_input->MouseDeltaY; |
179 |
– |
PlayerList[i]->LastInputTime = packet_input->Time; |
180 |
– |
|
181 |
– |
break; |
182 |
– |
} |
183 |
– |
case PK_PONG: |
184 |
– |
for(i = 0; i < max_connections; i++) { |
185 |
– |
if(PlayerList[i] != 0 && PlayerList[i]->ip == sender.sin_addr.S_un.S_addr) { |
186 |
– |
found_player = 1; |
187 |
– |
break; |
188 |
– |
} |
189 |
– |
} |
190 |
– |
|
191 |
– |
if(found_player == 0) break; |
192 |
– |
if(packet->ping != lastPingTime) |
193 |
– |
{ |
194 |
– |
PlayerList[i]->Ping = 999; |
195 |
– |
} |
196 |
– |
else |
197 |
– |
{ |
198 |
– |
PlayerList[i]->Ping = GetTickCount() - packet->ping; |
199 |
– |
} |
200 |
– |
break; |
201 |
– |
default: |
202 |
– |
DDrConsole_PrintF("Warning, recieved badly formed packet!"); |
203 |
– |
break; |
204 |
– |
} |
205 |
– |
return true; |
206 |
– |
} |
28 |
|
|
29 |
|
bool FLrServer_Run() |
30 |
|
{ |
115 |
|
FLrClient_GetPackets(); |
116 |
|
|
117 |
|
input_packet.id = PLAYER_INPUT; |
118 |
< |
input_packet.input_struct.Time = ONgGameState->GameTime; |
118 |
> |
// input_packet.input_struct.Time = ONgGameState->GameTime; |
119 |
|
input_packet.input_struct.Actions1 = ONgGameState->Input.Current.Actions1; |
120 |
|
input_packet.input_struct.Actions2 = ONgGameState->Input.Current.Actions2; |
121 |
|
input_packet.input_struct.MouseDeltaX = ONgGameState->Input.MouseDeltaX; |
122 |
|
input_packet.input_struct.MouseDeltaY = ONgGameState->Input.MouseDeltaY; |
123 |
+ |
input_packet.input_struct.DesiredFacing = ONgGameState->PlayerCharacter->DesiredFacing; |
124 |
|
|
125 |
|
sent_bytes = NetUDPSocket_Send(client_sock,(sockaddr *) &address, (char*)&input_packet, sizeof(input_struct) + FLATLINE_HEADER); |
126 |
|
|
131 |
|
if(!(server_started || client_connected)) return ONgGameState; |
132 |
|
|
133 |
|
|
312 |
– |
if(server_started) |
313 |
– |
{ |
314 |
– |
if(ONgGameState->GameTime % 120 == 0) |
315 |
– |
{ |
316 |
– |
FLsPingAll(); |
317 |
– |
} |
134 |
|
|
319 |
– |
if(PlayerList[0]) |
320 |
– |
{ |
321 |
– |
PlayerList[0]->InputFromClient.Actions1 = ONgGameState->Input.Current.Actions1; |
322 |
– |
PlayerList[0]->InputFromClient.Actions2 = ONgGameState->Input.Current.Actions2; |
323 |
– |
PlayerList[0]->InputFromClient.MouseDeltaX = ONgGameState->Input.MouseDeltaX; |
324 |
– |
PlayerList[0]->InputFromClient.MouseDeltaY = ONgGameState->Input.MouseDeltaY; |
325 |
– |
} |
326 |
– |
FLsSendPlayerData(); |
327 |
– |
} |
135 |
|
for(i = 0; i < max_connections; i++) { |
136 |
|
ActiveCharacter * Active_Player; |
137 |
|
Character* Player; |
149 |
|
continue; |
150 |
|
} |
151 |
|
|
152 |
+ |
if( server_started && i != 0 ) |
153 |
+ |
{ |
154 |
+ |
PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->FacingFromClient; |
155 |
+ |
} |
156 |
+ |
|
157 |
|
|
158 |
|
|
159 |
|
//Set the health properly first. |
160 |
+ |
//Always overridden by the server because of the chance of random damage and such |
161 |
|
if( client_connected && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Health) ) |
162 |
|
{ |
163 |
|
PlayerList[i]->Chr->MaxHealth = PlayerList[i]->Health.MaxHealth; |
164 |
|
ONrCharacter_SetHitPoints( PlayerList[i]->Chr, PlayerList[i]->Health.Health); |
165 |
< |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Health ); |
165 |
> |
//PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Health ); |
166 |
|
} |
167 |
+ |
|
168 |
|
//If the player is dead |
169 |
|
if( PlayerList[i]->Chr->Health == 0 ) |
170 |
|
|
228 |
|
|
229 |
|
PlayerList[i]->state = STATE_ALIVE; |
230 |
|
|
231 |
< |
if( DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Facing ) ) |
231 |
> |
if( client_connected && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Class ) ) |
232 |
> |
{ |
233 |
> |
if(PlayerList[i]->Class) |
234 |
> |
{ |
235 |
> |
ONrCharacter_SetCharacterClass( PlayerList[i]->Chr, PlayerList[i]->Class ); |
236 |
> |
} |
237 |
> |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Class ); |
238 |
> |
} |
239 |
> |
|
240 |
> |
if( client_connected && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Facing ) ) |
241 |
|
{ |
242 |
|
PlayerList[i]->Chr->Facing = PlayerList[i]->Facings.Facing; |
243 |
< |
PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->Facings.DesiredFacing; |
243 |
> |
if(i != client_slot) |
244 |
> |
{ |
245 |
> |
PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->Facings.DesiredFacing; |
246 |
> |
} |
247 |
|
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Facing ); |
248 |
|
} |
249 |
|
|
250 |
|
if(Active_Player == 0) continue; |
251 |
|
|
252 |
|
|
253 |
< |
if(client_connected) { |
254 |
< |
Active_Player->PlayingFilm.Flags = 1; |
429 |
< |
} |
430 |
< |
|
431 |
< |
|
432 |
< |
if( client_connected && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Position) ) |
433 |
< |
{ |
434 |
< |
Active_Player->PhyContext->Position = PlayerList[i]->Position; |
435 |
< |
|
436 |
< |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Position ); |
437 |
< |
} |
438 |
< |
|
439 |
< |
|
440 |
< |
|
441 |
< |
|
442 |
< |
if (!(Player->Flags & ONcCharacterFlag_BeingThrown) && |
443 |
< |
DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) && (PlayerList[i]->Animation)) |
444 |
< |
{ |
445 |
< |
// get a pointer to the animation |
446 |
< |
|
447 |
< |
|
448 |
< |
if (PlayerList[i]->Animation != Active_Player->Animation) |
449 |
< |
{ |
450 |
< |
|
451 |
< |
/////////////////////////////////// |
452 |
< |
//TODO: Check age of animation |
453 |
< |
/////////////////////////////////// |
454 |
< |
DDrConsole_PrintF("Changing animation from %s to %s", |
455 |
< |
TMrInstance_GetInstanceName( Active_Player->Animation ), |
456 |
< |
TMrInstance_GetInstanceName( PlayerList[i]->Animation ) ); |
457 |
< |
// set the characters animation |
458 |
< |
/*ONrCharacter_SetAnimationInternal(Player, |
459 |
< |
Active_Player, |
460 |
< |
Active_Player->AnimationToState, |
461 |
< |
0, |
462 |
< |
PlayerList[i]->Animation);*/ |
463 |
< |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
464 |
< |
ONrCharacter_SetAnimationExternal(Player, TRrAnimation_GetFrom(PlayerList[i]->Animation), PlayerList[i]->Animation, 1); |
465 |
< |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
466 |
< |
} |
467 |
< |
|
468 |
< |
|
469 |
< |
} |
470 |
< |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Animation ); |
471 |
< |
|
472 |
< |
//Don't update the frame if we are waiting to change the animation |
473 |
< |
if(DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_FramePing) && PlayerList[i]->Frame != -1 |
474 |
< |
//&& !DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) |
475 |
< |
) |
476 |
< |
{ |
477 |
< |
if( abs(PlayerList[i]->Frame - Active_Player->Frame) > 2 ) |
478 |
< |
{ |
479 |
< |
short AnimationLength; |
480 |
< |
AnimationLength = TRrAnimation_GetDuration(Active_Player->Animation); |
481 |
< |
if (PlayerList[i]->Frame >= AnimationLength) |
482 |
< |
{ |
483 |
< |
Active_Player->Frame = AnimationLength - 1; |
484 |
< |
//Active_Player->Frame = 0; |
485 |
< |
} |
486 |
< |
else |
487 |
< |
{ |
488 |
< |
Active_Player->Frame = PlayerList[i]->Frame; |
489 |
< |
} |
490 |
< |
} |
491 |
< |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_FramePing ); |
492 |
< |
} |
493 |
< |
|
494 |
< |
//Increment frame in case we were waiting |
495 |
< |
PlayerList[i]->Frame++; |
496 |
< |
|
497 |
< |
if (DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Throws) |
498 |
< |
&& PlayerList[i]->ThrowData.throwName[0] != 0) |
499 |
< |
{ |
500 |
< |
if(PlayerList[PlayerList[i]->ThrowData.throwing]) |
501 |
< |
{ |
502 |
< |
short throwTarget = PlayerList[PlayerList[i]->ThrowData.throwing]->spawnnumber; |
503 |
< |
if ((throwTarget != Active_Player->throwing) && |
504 |
< |
(PlayerList[i]->ThrowData.throwFrame < 10)) |
505 |
< |
{ |
506 |
< |
void *throw_animation; |
507 |
< |
ActiveCharacter* Target; |
508 |
< |
// get the animation |
509 |
< |
|
510 |
< |
TMrInstance_GetDataPtr( |
511 |
< |
'TRAM', |
512 |
< |
PlayerList[i]->ThrowData.throwName, |
513 |
< |
&throw_animation); |
514 |
< |
//if (error) return; |
515 |
< |
|
516 |
< |
// set the throw target |
517 |
< |
Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[throwTarget]; |
518 |
< |
Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); |
519 |
< |
if ((Target->Animation != throw_animation) && |
520 |
< |
// (OldAnimation != Animation) && |
521 |
< |
!(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown)) |
522 |
< |
{ |
523 |
< |
// set the throw variables |
524 |
< |
Active_Player->targetThrow = throw_animation; |
525 |
< |
Active_Player->throwing = throwTarget; |
526 |
< |
|
527 |
< |
// run the throw |
528 |
< |
ONrCharacter_NewAnimationHook(Player, Active_Player); |
529 |
< |
|
530 |
< |
if (Active_Player->ThrowTargetCharacter) |
531 |
< |
{ |
532 |
< |
Target->Frame += 2; |
533 |
< |
DDrConsole_PrintF("Thrown by player %hi", Player->Number ); |
534 |
< |
DDrStartupMessage("Thrown by player %hi", Player->Number ); |
535 |
< |
Target->thrownBy = Player->Number & 0x00ff; |
536 |
< |
} |
537 |
< |
} |
538 |
< |
} |
539 |
< |
} |
540 |
< |
else |
541 |
< |
{ |
542 |
< |
DDrConsole_PrintF("Warning, tried to throw nonexistant player %hi", |
543 |
< |
PlayerList[i]->ThrowData.throwing ); |
544 |
< |
} |
545 |
< |
} |
546 |
< |
|
547 |
< |
//Always discard old throw data, even if it isnt applied |
548 |
< |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Throws ); |
253 |
> |
|
254 |
> |
// Active_Player->PlayingFilm.Flags = 1; |
255 |
|
|
256 |
< |
Active_Input = &(Active_Player->Input); |
256 |
> |
Active_Input = &(Active_Player->Input); |
257 |
|
|
258 |
+ |
|
259 |
|
if( (server_started && i !=0) || !server_started ) |
260 |
|
{ |
261 |
|
Active_Input->Stop.Actions1 = ~PlayerList[i]->Input.Actions1 & Active_Input->Current.Actions1; |
267 |
|
Active_Input->Current.Actions2 = PlayerList[i]->Input.Actions2; |
268 |
|
Active_Input->Stopped.Actions1 = ~Active_Input->Current.Actions1; |
269 |
|
Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2; |
270 |
< |
Active_Input->MouseDeltaX = PlayerList[i]->Input.MouseDeltaX; |
271 |
< |
Active_Input->MouseDeltaY = PlayerList[i]->Input.MouseDeltaY; |
270 |
> |
if(client_connected && i == client_slot) |
271 |
> |
{ |
272 |
> |
Active_Input->MouseDeltaX = ONgGameState->Input.MouseDeltaX; |
273 |
> |
Active_Input->MouseDeltaY = ONgGameState->Input.MouseDeltaY; |
274 |
> |
} |
275 |
> |
else |
276 |
> |
{ |
277 |
> |
Active_Input->MouseDeltaX = PlayerList[i]->Input.MouseDeltaX; |
278 |
> |
Active_Input->MouseDeltaY = PlayerList[i]->Input.MouseDeltaY; |
279 |
> |
} |
280 |
|
} |
281 |
|
|
282 |
+ |
{ |
283 |
+ |
void* ConsoleAnimation = 0; |
284 |
+ |
TMrInstance_GetDataPtr( 'TRAM', "KONOKOwatch_idle", &ConsoleAnimation); |
285 |
+ |
|
286 |
+ |
if(!Active_Player->IsInAir && Active_Input->Current.Actions1 & (Action_Console | Action_PauseScreen) |
287 |
+ |
&& !(PlayerList[i]->Chr->Flags & ONcCharacterFlag_BeingThrown) |
288 |
+ |
&& Active_Player->ThrowTargetCharacter != -1) |
289 |
+ |
{ |
290 |
+ |
if(ConsoleAnimation && ConsoleAnimation != Active_Player->Animation) |
291 |
+ |
{ |
292 |
+ |
ONrCharacter_SetAnimationExternal(PlayerList[i]->Chr, Active_Player->AnimationFromState, ConsoleAnimation, 10); |
293 |
+ |
Player->Flags |= 0x00200000; |
294 |
+ |
Active_Player->ForcedAnimationFrames = -1;// TRrAnimation_GetDuration(ConsoleAnimation); |
295 |
+ |
} |
296 |
+ |
} |
297 |
+ |
else if(Active_Input->Stopped.Actions1 & (Action_Console | Action_PauseScreen) ) |
298 |
+ |
{ |
299 |
+ |
Active_Player->ForcedAnimationFrames = 0; |
300 |
+ |
} |
301 |
+ |
|
302 |
+ |
} |
303 |
+ |
|
304 |
|
//Check for character switching requests |
305 |
< |
if(server_started && PlayerList[i]->Chr->Health != 0 && PlayerList[i]->InputFromClient.Actions1 & Action_Block && PlayerList[i]->ShapeshiftCooldown < ONgGameState->GameTime) |
305 |
> |
if(server_started && PlayerList[i]->Chr->Health != 0 |
306 |
> |
&& PlayerList[i]->InputFromClient.Actions1 & Action_Block) |
307 |
|
{ |
308 |
< |
int error; |
308 |
> |
if( PlayerList[i]->ShapeshiftCooldown < ONgGameState->GameTime) |
309 |
> |
{ |
310 |
> |
int error; |
311 |
|
|
312 |
|
|
313 |
|
|
314 |
< |
ONCC *newClass; |
315 |
< |
short numClasses = (short)TMrInstance_GetTagCount('ONCC'); |
316 |
< |
/* |
317 |
< |
if(Active_Player->Input.Start.Actions1 & Action_Block) |
318 |
< |
{ |
314 |
> |
ONCC *newClass; |
315 |
> |
short numClasses = (short)TMrInstance_GetTagCount('ONCC'); |
316 |
> |
/* |
317 |
> |
if(Active_Player->Input.Start.Actions1 & Action_Block) |
318 |
> |
{ |
319 |
|
//This might not be getting hit. Find out why, eh? |
320 |
|
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15; |
321 |
< |
} |
322 |
< |
else |
323 |
< |
{ |
321 |
> |
} |
322 |
> |
else |
323 |
> |
{ |
324 |
|
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 5; |
325 |
< |
} |
326 |
< |
*/ |
327 |
< |
if (PlayerList[i]->InputFromClient.Actions1 & Action_Crouch) { |
328 |
< |
Player->ONCCnumber += numClasses - 1; |
329 |
< |
} |
330 |
< |
else { |
331 |
< |
Player->ONCCnumber += 1; |
332 |
< |
} |
325 |
> |
} |
326 |
> |
*/ |
327 |
> |
|
328 |
> |
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15; |
329 |
> |
|
330 |
> |
if (PlayerList[i]->InputFromClient.Actions1 & Action_Crouch) { |
331 |
> |
Player->ONCCnumber += numClasses - 1; |
332 |
> |
} |
333 |
> |
else { |
334 |
> |
Player->ONCCnumber += 1; |
335 |
> |
} |
336 |
> |
|
337 |
> |
if (numClasses > 0) { |
338 |
> |
Player->ONCCnumber = Player->ONCCnumber % numClasses; |
339 |
> |
|
340 |
> |
error = TMrInstance_GetDataPtr_ByNumber('ONCC', Player->ONCCnumber, &newClass); |
341 |
> |
|
342 |
> |
if ((newClass != NULL) && (!error)) { |
343 |
> |
ONrCharacter_SetCharacterClass(Player, newClass); |
344 |
> |
} |
345 |
> |
} |
346 |
> |
|
347 |
> |
} |
348 |
> |
} |
349 |
> |
else |
350 |
> |
{ |
351 |
> |
PlayerList[i]->ShapeshiftCooldown = 0; |
352 |
> |
} |
353 |
> |
if(client_connected) { |
354 |
> |
|
355 |
> |
if( DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Position) ) |
356 |
> |
{ |
357 |
> |
//Active_Player->PhyContext->Position = PlayerList[i]->Position; |
358 |
> |
|
359 |
> |
Active_Player->PhyContext->Position.X = |
360 |
> |
(PlayerList[i]->Position.X + Active_Player->PhyContext->Position.X) / 2; |
361 |
> |
|
362 |
> |
Active_Player->PhyContext->Position.Y = |
363 |
> |
(PlayerList[i]->Position.Y + Active_Player->PhyContext->Position.Y) / 2; |
364 |
> |
|
365 |
> |
Active_Player->PhyContext->Position.Z = |
366 |
> |
(PlayerList[i]->Position.Z + Active_Player->PhyContext->Position.Z) / 2; |
367 |
> |
|
368 |
> |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Position ); |
369 |
> |
} |
370 |
> |
|
371 |
> |
|
372 |
> |
|
373 |
> |
|
374 |
> |
if (!(Player->Flags & ONcCharacterFlag_BeingThrown) && |
375 |
> |
DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) && (PlayerList[i]->Animation)) |
376 |
> |
{ |
377 |
> |
// get a pointer to the animation |
378 |
|
|
594 |
– |
if (numClasses > 0) { |
595 |
– |
Player->ONCCnumber = Player->ONCCnumber % numClasses; |
379 |
|
|
380 |
< |
error = TMrInstance_GetDataPtr_ByNumber('ONCC', Player->ONCCnumber, &newClass); |
380 |
> |
if (PlayerList[i]->Animation != Active_Player->Animation) |
381 |
> |
{ |
382 |
|
|
383 |
< |
if ((newClass != NULL) && (!error)) { |
384 |
< |
ONrCharacter_SetCharacterClass(Player, newClass); |
383 |
> |
/////////////////////////////////// |
384 |
> |
//TODO: Check age of animation |
385 |
> |
/////////////////////////////////// |
386 |
> |
// set the characters animation |
387 |
> |
/*ONrCharacter_SetAnimationInternal(Player, |
388 |
> |
Active_Player, |
389 |
> |
Active_Player->AnimationToState, |
390 |
> |
0, |
391 |
> |
PlayerList[i]->Animation);*/ |
392 |
> |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
393 |
> |
ONrCharacter_SetAnimationExternal(Player, TRrAnimation_GetFrom(PlayerList[i]->Animation), PlayerList[i]->Animation, 1); |
394 |
> |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
395 |
|
} |
396 |
+ |
|
397 |
+ |
|
398 |
|
} |
399 |
+ |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Animation ); |
400 |
+ |
|
401 |
+ |
//Disabled Frame syncing for now. In most cases it won't be useful. |
402 |
+ |
if(0 && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_FramePing) && PlayerList[i]->Frame != -1 |
403 |
+ |
//&& !DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) |
404 |
+ |
) |
405 |
+ |
{ |
406 |
+ |
if( abs(PlayerList[i]->Frame - Active_Player->Frame) > 2 ) |
407 |
+ |
{ |
408 |
+ |
short AnimationLength; |
409 |
+ |
AnimationLength = TRrAnimation_GetDuration(Active_Player->Animation); |
410 |
+ |
if (PlayerList[i]->Frame >= AnimationLength) |
411 |
+ |
{ |
412 |
+ |
Active_Player->Frame = AnimationLength - 1; |
413 |
+ |
//Active_Player->Frame = 0; |
414 |
+ |
} |
415 |
+ |
else |
416 |
+ |
{ |
417 |
+ |
Active_Player->Frame = PlayerList[i]->Frame; |
418 |
+ |
} |
419 |
+ |
} |
420 |
+ |
|
421 |
+ |
} |
422 |
+ |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_FramePing ); |
423 |
|
|
424 |
+ |
//Increment frame in case we were waiting |
425 |
+ |
PlayerList[i]->Frame++; |
426 |
+ |
|
427 |
+ |
if (DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Throws) |
428 |
+ |
&& PlayerList[i]->ThrowData.throwName[0] != 0) |
429 |
+ |
{ |
430 |
+ |
if(PlayerList[PlayerList[i]->ThrowData.throwing]) |
431 |
+ |
{ |
432 |
+ |
short throwTarget = PlayerList[PlayerList[i]->ThrowData.throwing]->spawnnumber; |
433 |
+ |
/*if ((throwTarget != Active_Player->throwing) && |
434 |
+ |
(PlayerList[i]->ThrowData.throwFrame < 10))*/ |
435 |
+ |
{ |
436 |
+ |
void *throw_animation; |
437 |
+ |
ActiveCharacter* Target; |
438 |
+ |
// get the animation |
439 |
+ |
|
440 |
+ |
TMrInstance_GetDataPtr( |
441 |
+ |
'TRAM', |
442 |
+ |
PlayerList[i]->ThrowData.throwName, |
443 |
+ |
&throw_animation); |
444 |
+ |
//if (error) return; |
445 |
+ |
|
446 |
+ |
// set the throw target |
447 |
+ |
Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[throwTarget]; |
448 |
+ |
Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); |
449 |
+ |
//if (/*(Target->Animation != throw_animation) &&*/ |
450 |
+ |
// (OldAnimation != Animation) && |
451 |
+ |
// !(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown)) |
452 |
+ |
// Target->thrownBy == - |
453 |
+ |
{ |
454 |
+ |
// set the throw variables |
455 |
+ |
Active_Player->targetThrow = throw_animation; |
456 |
+ |
Active_Player->throwing = throwTarget; |
457 |
+ |
|
458 |
+ |
// run the throw |
459 |
+ |
ONrCharacter_NewAnimationHook(Player, Active_Player); |
460 |
+ |
|
461 |
+ |
//if (Active_Player->ThrowTargetCharacter) |
462 |
+ |
{ |
463 |
+ |
// Target->Frame += 2; |
464 |
+ |
//DDrConsole_PrintF("Thrown by player %hi", Player->Number ); |
465 |
+ |
//DDrStartupMessage("Thrown by player %hi", Player->Number ); |
466 |
+ |
Target->thrownBy = Player->Number & 0x00ff; |
467 |
+ |
} |
468 |
+ |
} |
469 |
+ |
} |
470 |
+ |
} |
471 |
+ |
else |
472 |
+ |
{ |
473 |
+ |
DDrConsole_PrintF("Warning, tried to throw nonexistant player %hi", |
474 |
+ |
PlayerList[i]->ThrowData.throwing ); |
475 |
+ |
} |
476 |
+ |
} |
477 |
+ |
|
478 |
+ |
//Always discard old throw data, even if it isnt applied |
479 |
+ |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Throws ); |
480 |
|
} |
481 |
|
|
482 |
|
|
483 |
|
} |
484 |
|
|
485 |
+ |
if(server_started) |
486 |
+ |
{ |
487 |
+ |
if(ONgGameState->GameTime % 120 == 0) |
488 |
+ |
{ |
489 |
+ |
FLsPingAll(); |
490 |
+ |
} |
491 |
+ |
|
492 |
+ |
if(PlayerList[0]) |
493 |
+ |
{ |
494 |
+ |
PlayerList[0]->InputFromClient.Actions1 = ONgGameState->Input.Current.Actions1; |
495 |
+ |
PlayerList[0]->InputFromClient.Actions2 = ONgGameState->Input.Current.Actions2; |
496 |
+ |
PlayerList[0]->InputFromClient.MouseDeltaX = ONgGameState->Input.MouseDeltaX; |
497 |
+ |
PlayerList[0]->InputFromClient.MouseDeltaY = ONgGameState->Input.MouseDeltaY; |
498 |
+ |
} |
499 |
+ |
FLsSendPlayerData(); |
500 |
+ |
} |
501 |
|
MultiplayerStatus.PleaseUpdateAllPlayers = 0; |
502 |
|
return ONgGameState; |
503 |
|
} |
542 |
|
const int white = 0x00FFFFFF; |
543 |
|
const int green = 0x0000FF00; |
544 |
|
const int red = 0x00FF0000; |
545 |
+ |
const int blue = 0x000000FF; |
546 |
|
int i; |
547 |
|
char DrawString[255]; |
548 |
|
const int LineHeight = 15; |
549 |
< |
IMtPoint2D DrawLocation = {20, 20}; |
549 |
> |
IMtPoint2D DrawLocation = {25, 20}; |
550 |
|
TSrContext_SetShade(ScoreboardInstance, white); |
551 |
|
TSrContext_DrawText(ScoreboardInstance, "Oni Flatline build " __DATE__ " " __TIME__, 255, 0, &DrawLocation); |
552 |
+ |
TSrContext_SetShade(ScoreboardInstance, white); |
553 |
|
DrawLocation.y += LineHeight; |
554 |
+ |
DrawLocation.x = 25; |
555 |
|
TSrContext_DrawText(ScoreboardInstance, "Name", 255, 0, &DrawLocation); |
556 |
|
DrawLocation.x += 150; |
557 |
|
TSrContext_DrawText(ScoreboardInstance, "Score", 255, 0, &DrawLocation); |
561 |
|
{ |
562 |
|
if(PlayerList[i] == 0 || PlayerList[i]->Chr == 0) continue; |
563 |
|
|
564 |
< |
DrawLocation.x = 20; |
564 |
> |
DrawLocation.x = 10; |
565 |
|
DrawLocation.y += LineHeight; |
566 |
|
|
567 |
+ |
sprintf(DrawString, "%i.", i ); |
568 |
+ |
TSrContext_DrawText(ScoreboardInstance, DrawString, 255, 0, &DrawLocation); |
569 |
+ |
DrawLocation.x += 15; |
570 |
+ |
|
571 |
|
if(PlayerList[i]->Chr && PlayerList[i]->Chr->Health == 0) |
572 |
|
{ |
573 |
|
TSrContext_SetShade(ScoreboardInstance, red); |