26 |
|
#define BETTER_SYNC |
27 |
|
|
28 |
|
|
29 |
< |
bool FLrServer_Run() |
30 |
< |
{ |
31 |
< |
// Get the local hostname |
32 |
< |
char szHostName[255]; |
33 |
< |
struct hostent *host_entry; |
34 |
< |
gethostname(szHostName, 255); |
35 |
< |
|
36 |
< |
host_entry=gethostbyname(szHostName); |
37 |
< |
DDrConsole_PrintF("Server started at %s...", inet_ntoa (*(struct in_addr *)*host_entry->h_addr_list)); |
38 |
< |
return NetUDPServer_Listen(27777, FLrServer_PacketCallback); |
39 |
< |
} |
29 |
> |
|
30 |
|
|
31 |
|
short TRrAnimation_GetType(char* anim) |
32 |
|
{ |
33 |
|
return *(short*)(anim + 0x15A); |
34 |
|
} |
35 |
|
|
36 |
< |
void ONrCharacter_SetAnimationInternal(Character* Char, ActiveCharacter* AChar, |
37 |
< |
short inFromState, short inNextAnimType, const void *TRAM) |
38 |
< |
{ |
39 |
< |
ONCC *ONCC = Char->ONCC; |
40 |
< |
void *TRAC = ONCC->TRAC; |
41 |
< |
short index = Char->Number; |
42 |
< |
short animType; |
43 |
< |
|
44 |
< |
if (TRAM == 0) return; |
45 |
< |
|
46 |
< |
animType = TRrAnimation_GetType(TRAM); |
47 |
< |
|
48 |
< |
AChar->Animation = TRAM; |
49 |
< |
AChar->Frame = 0; |
50 |
< |
AChar->AnimationFromState = inFromState; |
51 |
< |
AChar->AnimationType = animType; |
52 |
< |
|
53 |
< |
AChar->NextAnimationType= inNextAnimType; |
54 |
< |
AChar->AnimationToState = TRrAnimation_GetTo(TRAM); |
55 |
< |
|
56 |
< |
return; |
36 |
> |
void ONrCharacter_SetAnimationInternal(Character* Char, ActiveCharacter* AChar, |
37 |
> |
short inFromState, short inNextAnimType, const void *TRAM) |
38 |
> |
{ |
39 |
> |
ONCC *ONCC = Char->ONCC; |
40 |
> |
void *TRAC = ONCC->TRAC; |
41 |
> |
short index = Char->Number; |
42 |
> |
short animType; |
43 |
> |
|
44 |
> |
if (TRAM == 0) return; |
45 |
> |
|
46 |
> |
animType = TRrAnimation_GetType(TRAM); |
47 |
> |
|
48 |
> |
AChar->Animation = TRAM; |
49 |
> |
AChar->Frame = 0; |
50 |
> |
AChar->AnimationFromState = inFromState; |
51 |
> |
AChar->AnimationType = animType; |
52 |
> |
|
53 |
> |
AChar->NextAnimationType= inNextAnimType; |
54 |
> |
AChar->AnimationToState = TRrAnimation_GetTo(TRAM); |
55 |
> |
|
56 |
> |
return; |
57 |
|
} |
58 |
|
|
59 |
|
|
82 |
|
} |
83 |
|
return -1; |
84 |
|
} |
85 |
< |
typedef struct |
86 |
< |
{ |
87 |
< |
uint16_t x; |
88 |
< |
uint16_t y; |
89 |
< |
|
85 |
> |
typedef struct |
86 |
> |
{ |
87 |
> |
uint16_t x; |
88 |
> |
uint16_t y; |
89 |
> |
|
90 |
|
} IMtPoint2D; |
91 |
|
static flatline_packet cache_input = {0}; |
92 |
|
|
297 |
|
{ |
298 |
|
if( PlayerList[i]->ShapeshiftCooldown < ONgGameState->GameTime) |
299 |
|
{ |
300 |
< |
int error; |
301 |
< |
|
302 |
< |
|
303 |
< |
|
304 |
< |
ONCC *newClass; |
305 |
< |
short numClasses = (short)TMrInstance_GetTagCount('ONCC'); |
306 |
< |
/* |
307 |
< |
if(Active_Player->Input.Start.Actions1 & Action_Block) |
308 |
< |
{ |
309 |
< |
//This might not be getting hit. Find out why, eh? |
310 |
< |
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15; |
311 |
< |
} |
312 |
< |
else |
313 |
< |
{ |
314 |
< |
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 5; |
315 |
< |
} |
316 |
< |
*/ |
317 |
< |
|
318 |
< |
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15; |
319 |
< |
|
320 |
< |
if (PlayerList[i]->InputFromClient.Actions1 & Action_Crouch) { |
321 |
< |
Player->ONCCnumber += numClasses - 1; |
322 |
< |
} |
323 |
< |
else { |
324 |
< |
Player->ONCCnumber += 1; |
325 |
< |
} |
326 |
< |
|
327 |
< |
if (numClasses > 0) { |
328 |
< |
Player->ONCCnumber = Player->ONCCnumber % numClasses; |
329 |
< |
|
330 |
< |
error = TMrInstance_GetDataPtr_ByNumber('ONCC', Player->ONCCnumber, &newClass); |
331 |
< |
|
332 |
< |
if ((newClass != NULL) && (!error)) { |
333 |
< |
ONrCharacter_SetCharacterClass(Player, newClass); |
334 |
< |
} |
335 |
< |
} |
300 |
> |
int error; |
301 |
> |
|
302 |
> |
|
303 |
> |
|
304 |
> |
ONCC *newClass; |
305 |
> |
short numClasses = (short)TMrInstance_GetTagCount('ONCC'); |
306 |
> |
/* |
307 |
> |
if(Active_Player->Input.Start.Actions1 & Action_Block) |
308 |
> |
{ |
309 |
> |
//This might not be getting hit. Find out why, eh? |
310 |
> |
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15; |
311 |
> |
} |
312 |
> |
else |
313 |
> |
{ |
314 |
> |
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 5; |
315 |
> |
} |
316 |
> |
*/ |
317 |
> |
|
318 |
> |
PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15; |
319 |
> |
|
320 |
> |
if (PlayerList[i]->InputFromClient.Actions1 & Action_Crouch) { |
321 |
> |
Player->ONCCnumber += numClasses - 1; |
322 |
> |
} |
323 |
> |
else { |
324 |
> |
Player->ONCCnumber += 1; |
325 |
> |
} |
326 |
> |
|
327 |
> |
if (numClasses > 0) { |
328 |
> |
Player->ONCCnumber = Player->ONCCnumber % numClasses; |
329 |
> |
|
330 |
> |
error = TMrInstance_GetDataPtr_ByNumber('ONCC', Player->ONCCnumber, &newClass); |
331 |
> |
|
332 |
> |
if ((newClass != NULL) && (!error)) { |
333 |
> |
ONrCharacter_SetCharacterClass(Player, newClass); |
334 |
> |
} |
335 |
> |
} |
336 |
|
|
337 |
|
} |
338 |
|
} |
361 |
|
|
362 |
|
|
363 |
|
|
364 |
< |
if (!(Player->Flags & ONcCharacterFlag_BeingThrown) && |
365 |
< |
DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) && (PlayerList[i]->Animation)) |
366 |
< |
{ |
367 |
< |
// get a pointer to the animation |
368 |
< |
|
369 |
< |
|
370 |
< |
if (PlayerList[i]->Animation != Active_Player->Animation) |
371 |
< |
{ |
372 |
< |
|
373 |
< |
/////////////////////////////////// |
374 |
< |
//TODO: Check age of animation |
375 |
< |
/////////////////////////////////// |
376 |
< |
// set the characters animation |
377 |
< |
/*ONrCharacter_SetAnimationInternal(Player, |
378 |
< |
Active_Player, |
379 |
< |
Active_Player->AnimationToState, |
380 |
< |
0, |
381 |
< |
PlayerList[i]->Animation);*/ |
382 |
< |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
383 |
< |
ONrCharacter_SetAnimationExternal(Player, TRrAnimation_GetFrom(PlayerList[i]->Animation), PlayerList[i]->Animation, 1); |
384 |
< |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
385 |
< |
} |
386 |
< |
|
387 |
< |
|
388 |
< |
} |
389 |
< |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Animation ); |
390 |
< |
|
391 |
< |
//Disabled Frame syncing for now. In most cases it won't be useful. |
392 |
< |
if(0 && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_FramePing) && PlayerList[i]->Frame != -1 |
393 |
< |
//&& !DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) |
394 |
< |
) |
395 |
< |
{ |
396 |
< |
if( abs(PlayerList[i]->Frame - Active_Player->Frame) > 2 ) |
397 |
< |
{ |
398 |
< |
short AnimationLength; |
399 |
< |
AnimationLength = TRrAnimation_GetDuration(Active_Player->Animation); |
400 |
< |
if (PlayerList[i]->Frame >= AnimationLength) |
401 |
< |
{ |
402 |
< |
Active_Player->Frame = AnimationLength - 1; |
403 |
< |
//Active_Player->Frame = 0; |
404 |
< |
} |
405 |
< |
else |
406 |
< |
{ |
407 |
< |
Active_Player->Frame = PlayerList[i]->Frame; |
408 |
< |
} |
409 |
< |
} |
410 |
< |
|
364 |
> |
if (!(Player->Flags & ONcCharacterFlag_BeingThrown) && |
365 |
> |
DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) && (PlayerList[i]->Animation)) |
366 |
> |
{ |
367 |
> |
// get a pointer to the animation |
368 |
> |
|
369 |
> |
|
370 |
> |
if (PlayerList[i]->Animation != Active_Player->Animation) |
371 |
> |
{ |
372 |
> |
|
373 |
> |
/////////////////////////////////// |
374 |
> |
//TODO: Check age of animation |
375 |
> |
/////////////////////////////////// |
376 |
> |
// set the characters animation |
377 |
> |
/*ONrCharacter_SetAnimationInternal(Player, |
378 |
> |
Active_Player, |
379 |
> |
Active_Player->AnimationToState, |
380 |
> |
0, |
381 |
> |
PlayerList[i]->Animation);*/ |
382 |
> |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
383 |
> |
ONrCharacter_SetAnimationExternal(Player, TRrAnimation_GetFrom(PlayerList[i]->Animation), PlayerList[i]->Animation, 1); |
384 |
> |
//ONrCharacter_NewAnimationHook(Player, Active_Player); |
385 |
> |
} |
386 |
> |
|
387 |
> |
|
388 |
> |
} |
389 |
> |
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Animation ); |
390 |
> |
|
391 |
> |
//Disabled Frame syncing for now. In most cases it won't be useful. |
392 |
> |
if(0 && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_FramePing) && PlayerList[i]->Frame != -1 |
393 |
> |
//&& !DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) |
394 |
> |
) |
395 |
> |
{ |
396 |
> |
if( abs(PlayerList[i]->Frame - Active_Player->Frame) > 2 ) |
397 |
> |
{ |
398 |
> |
short AnimationLength; |
399 |
> |
AnimationLength = TRrAnimation_GetDuration(Active_Player->Animation); |
400 |
> |
if (PlayerList[i]->Frame >= AnimationLength) |
401 |
> |
{ |
402 |
> |
Active_Player->Frame = AnimationLength - 1; |
403 |
> |
//Active_Player->Frame = 0; |
404 |
> |
} |
405 |
> |
else |
406 |
> |
{ |
407 |
> |
Active_Player->Frame = PlayerList[i]->Frame; |
408 |
> |
} |
409 |
> |
} |
410 |
> |
|
411 |
|
} |
412 |
|
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_FramePing ); |
413 |
|
|
414 |
|
//Increment frame in case we were waiting |
415 |
|
PlayerList[i]->Frame++; |
416 |
|
|
417 |
< |
if (DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Throws) |
418 |
< |
&& PlayerList[i]->ThrowData.throwName[0] != 0) |
419 |
< |
{ |
420 |
< |
if(PlayerList[PlayerList[i]->ThrowData.throwing]) |
421 |
< |
{ |
422 |
< |
short throwTarget = PlayerList[PlayerList[i]->ThrowData.throwing]->spawnnumber; |
423 |
< |
/*if ((throwTarget != Active_Player->throwing) && |
424 |
< |
(PlayerList[i]->ThrowData.throwFrame < 10))*/ |
425 |
< |
{ |
426 |
< |
void *throw_animation; |
427 |
< |
ActiveCharacter* Target; |
428 |
< |
// get the animation |
429 |
< |
|
430 |
< |
TMrInstance_GetDataPtr( |
431 |
< |
'TRAM', |
432 |
< |
PlayerList[i]->ThrowData.throwName, |
433 |
< |
&throw_animation); |
434 |
< |
//if (error) return; |
435 |
< |
|
436 |
< |
// set the throw target |
437 |
< |
Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[throwTarget]; |
438 |
< |
Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); |
439 |
< |
//if (/*(Target->Animation != throw_animation) &&*/ |
440 |
< |
// (OldAnimation != Animation) && |
441 |
< |
// !(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown)) |
442 |
< |
// Target->thrownBy == - |
443 |
< |
{ |
444 |
< |
// set the throw variables |
445 |
< |
Active_Player->targetThrow = throw_animation; |
446 |
< |
Active_Player->throwing = throwTarget; |
447 |
< |
|
448 |
< |
// run the throw |
449 |
< |
ONrCharacter_NewAnimationHook(Player, Active_Player); |
450 |
< |
|
451 |
< |
//if (Active_Player->ThrowTargetCharacter) |
452 |
< |
{ |
453 |
< |
// Target->Frame += 2; |
454 |
< |
//DDrConsole_PrintF("Thrown by player %hi", Player->Number ); |
455 |
< |
//DDrStartupMessage("Thrown by player %hi", Player->Number ); |
456 |
< |
Target->thrownBy = Player->Number & 0x00ff; |
457 |
< |
} |
458 |
< |
} |
459 |
< |
} |
460 |
< |
} |
461 |
< |
else |
462 |
< |
{ |
463 |
< |
DDrConsole_PrintF("Warning, tried to throw nonexistant player %hi", |
464 |
< |
PlayerList[i]->ThrowData.throwing ); |
465 |
< |
} |
466 |
< |
} |
467 |
< |
|
468 |
< |
//Always discard old throw data, even if it isnt applied |
417 |
> |
if (DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Throws) |
418 |
> |
&& PlayerList[i]->ThrowData.throwName[0] != 0) |
419 |
> |
{ |
420 |
> |
if(PlayerList[PlayerList[i]->ThrowData.throwing]) |
421 |
> |
{ |
422 |
> |
short throwTarget = PlayerList[PlayerList[i]->ThrowData.throwing]->spawnnumber; |
423 |
> |
/*if ((throwTarget != Active_Player->throwing) && |
424 |
> |
(PlayerList[i]->ThrowData.throwFrame < 10))*/ |
425 |
> |
{ |
426 |
> |
void *throw_animation; |
427 |
> |
ActiveCharacter* Target; |
428 |
> |
// get the animation |
429 |
> |
|
430 |
> |
TMrInstance_GetDataPtr( |
431 |
> |
'TRAM', |
432 |
> |
PlayerList[i]->ThrowData.throwName, |
433 |
> |
&throw_animation); |
434 |
> |
//if (error) return; |
435 |
> |
|
436 |
> |
// set the throw target |
437 |
> |
Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[throwTarget]; |
438 |
> |
Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter); |
439 |
> |
//if (/*(Target->Animation != throw_animation) &&*/ |
440 |
> |
// (OldAnimation != Animation) && |
441 |
> |
// !(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown)) |
442 |
> |
// Target->thrownBy == - |
443 |
> |
{ |
444 |
> |
// set the throw variables |
445 |
> |
Active_Player->targetThrow = throw_animation; |
446 |
> |
Active_Player->throwing = throwTarget; |
447 |
> |
|
448 |
> |
// run the throw |
449 |
> |
ONrCharacter_NewAnimationHook(Player, Active_Player); |
450 |
> |
|
451 |
> |
//if (Active_Player->ThrowTargetCharacter) |
452 |
> |
{ |
453 |
> |
// Target->Frame += 2; |
454 |
> |
//DDrConsole_PrintF("Thrown by player %hi", Player->Number ); |
455 |
> |
//DDrStartupMessage("Thrown by player %hi", Player->Number ); |
456 |
> |
Target->thrownBy = Player->Number & 0x00ff; |
457 |
> |
} |
458 |
> |
} |
459 |
> |
} |
460 |
> |
} |
461 |
> |
else |
462 |
> |
{ |
463 |
> |
DDrConsole_PrintF("Warning, tried to throw nonexistant player %hi", |
464 |
> |
PlayerList[i]->ThrowData.throwing ); |
465 |
> |
} |
466 |
> |
} |
467 |
> |
|
468 |
> |
//Always discard old throw data, even if it isnt applied |
469 |
|
PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Throws ); |
470 |
|
} |
471 |
|
|