[578] | 1 | #include "Flatline.h"
|
---|
| 2 | #include "Oni_Character.h"
|
---|
[579] | 3 | #include "Flatline_Client.h"
|
---|
[578] | 4 | #include "Flatline_Server.h"
|
---|
[579] | 5 | #include "Flatline_Events.h"
|
---|
[585] | 6 | #include "Daodan_Utility.h"
|
---|
[582] | 7 | #include <Windows.h>
|
---|
[578] | 8 | //#include <sys/time.h>
|
---|
| 9 | #include <time.h>
|
---|
[582] | 10 | #include <float.h>
|
---|
| 11 | #define isnan(x) ((x) != (x))
|
---|
[578] | 12 | uint32_t last1 = 0; uint32_t last2 = 0;
|
---|
| 13 | player_info Players[MAX_PLAYERS] = {{0}, {0}, {0}, {0}};
|
---|
| 14 | player_info * PlayerList[MAX_CONNECTIONS] = {0};
|
---|
[582] | 15 | multiplayer_status MultiplayerStatus;
|
---|
[580] | 16 | unsigned int lastPingTime;
|
---|
| 17 |
|
---|
[578] | 18 | const char * Rejection_Messages[][255] = {
|
---|
| 19 | {"Server is full"},
|
---|
| 20 | {"-2"},
|
---|
| 21 | {"-3"},
|
---|
| 22 | {"-4"},
|
---|
| 23 | {"-5"},
|
---|
| 24 | };
|
---|
| 25 |
|
---|
| 26 | #define BETTER_SYNC
|
---|
| 27 |
|
---|
| 28 |
|
---|
| 29 |
|
---|
| 30 |
|
---|
| 31 | short TRrAnimation_GetType(char* anim)
|
---|
| 32 | {
|
---|
| 33 | return *(short*)(anim + 0x15A);
|
---|
| 34 | }
|
---|
| 35 |
|
---|
[588] | 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;
|
---|
[578] | 57 | }
|
---|
| 58 |
|
---|
| 59 |
|
---|
[580] | 60 |
|
---|
[578] | 61 |
|
---|
[582] | 62 |
|
---|
[583] | 63 |
|
---|
[578] | 64 | //wtf, this needs cleaned up...
|
---|
| 65 | player_info *FLr_FindEmptySlot() {
|
---|
| 66 | int j;
|
---|
| 67 | for(j = 0; j < MAX_PLAYERS; j++) {
|
---|
| 68 | if (Players[j].ip == 0) {
|
---|
| 69 | return &Players[j];
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 | return 0;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | extern uint16_t max_connections;
|
---|
| 76 | uint16_t FLr_FindEmptyListSlot() {
|
---|
| 77 | int j;
|
---|
| 78 | for(j = 0; j < max_connections; j++) {
|
---|
| 79 | if (PlayerList[j] == 0) {
|
---|
| 80 | return j;
|
---|
| 81 | }
|
---|
| 82 | }
|
---|
| 83 | return -1;
|
---|
| 84 | }
|
---|
[588] | 85 | typedef struct
|
---|
| 86 | {
|
---|
| 87 | uint16_t x;
|
---|
| 88 | uint16_t y;
|
---|
[580] | 89 | } IMtPoint2D;
|
---|
[578] | 90 | static flatline_packet cache_input = {0};
|
---|
[583] | 91 |
|
---|
[582] | 92 |
|
---|
[578] | 93 | void * ONICALL FLrInput_Update_Keys(void)
|
---|
| 94 | {
|
---|
[583] | 95 | uint32_t i;
|
---|
[581] | 96 | flatline_packet all_input = {0};
|
---|
[582] | 97 | int16_t InputIndex = 0;
|
---|
| 98 |
|
---|
[578] | 99 | if(client_connected)
|
---|
| 100 | {
|
---|
| 101 | int sent_bytes;
|
---|
| 102 | flatline_packet input_packet = {0};
|
---|
[582] | 103 |
|
---|
| 104 | FLrClient_GetPackets();
|
---|
| 105 |
|
---|
[578] | 106 | input_packet.id = PLAYER_INPUT;
|
---|
[586] | 107 | // input_packet.input_struct.Time = ONgGameState->GameTime;
|
---|
[585] | 108 | input_packet.input_struct.Actions1 = ONgGameState->Input.Current.Actions1;
|
---|
| 109 | input_packet.input_struct.Actions2 = ONgGameState->Input.Current.Actions2;
|
---|
| 110 | input_packet.input_struct.MouseDeltaX = ONgGameState->Input.MouseDeltaX;
|
---|
| 111 | input_packet.input_struct.MouseDeltaY = ONgGameState->Input.MouseDeltaY;
|
---|
[586] | 112 | input_packet.input_struct.DesiredFacing = ONgGameState->PlayerCharacter->DesiredFacing;
|
---|
[580] | 113 |
|
---|
[578] | 114 | sent_bytes = NetUDPSocket_Send(client_sock,(sockaddr *) &address, (char*)&input_packet, sizeof(input_struct) + FLATLINE_HEADER);
|
---|
[580] | 115 |
|
---|
[578] | 116 | //return ONgGameState;
|
---|
| 117 | }
|
---|
[579] | 118 |
|
---|
| 119 |
|
---|
[578] | 120 | if(!(server_started || client_connected)) return ONgGameState;
|
---|
| 121 |
|
---|
[581] | 122 |
|
---|
[580] | 123 |
|
---|
[578] | 124 | for(i = 0; i < max_connections; i++) {
|
---|
| 125 | ActiveCharacter * Active_Player;
|
---|
| 126 | Character* Player;
|
---|
| 127 | GameInput * Active_Input;
|
---|
| 128 | if(PlayerList[i] == 0) continue;
|
---|
[583] | 129 |
|
---|
[585] | 130 |
|
---|
| 131 |
|
---|
[582] | 132 | Player = PlayerList[i]->Chr;
|
---|
[583] | 133 | Active_Player = ONrGetActiveCharacter( PlayerList[i]->Chr);
|
---|
| 134 |
|
---|
| 135 | if(!Player)
|
---|
[582] | 136 | {
|
---|
[583] | 137 | DDrConsole_Print("Warning, missing Character!");
|
---|
| 138 | continue;
|
---|
| 139 | }
|
---|
[580] | 140 |
|
---|
[586] | 141 | if( server_started && i != 0 )
|
---|
| 142 | {
|
---|
| 143 | PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->FacingFromClient;
|
---|
| 144 | }
|
---|
[580] | 145 |
|
---|
[586] | 146 |
|
---|
[583] | 147 |
|
---|
| 148 | //Set the health properly first.
|
---|
[586] | 149 | //Always overridden by the server because of the chance of random damage and such
|
---|
[584] | 150 | if( client_connected && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Health) )
|
---|
[579] | 151 | {
|
---|
[584] | 152 | PlayerList[i]->Chr->MaxHealth = PlayerList[i]->Health.MaxHealth;
|
---|
| 153 | ONrCharacter_SetHitPoints( PlayerList[i]->Chr, PlayerList[i]->Health.Health);
|
---|
[586] | 154 | //PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Health );
|
---|
[583] | 155 | }
|
---|
[586] | 156 |
|
---|
[583] | 157 | //If the player is dead
|
---|
| 158 | if( PlayerList[i]->Chr->Health == 0 )
|
---|
| 159 |
|
---|
| 160 | {
|
---|
[579] | 161 | const short TicksToRespawn = 3 * 60;
|
---|
[583] | 162 |
|
---|
| 163 | //Permanently kill off dumb AI
|
---|
| 164 | if(PlayerList[i]->flags & PF_SCRIPTEDAI)
|
---|
| 165 | {
|
---|
| 166 | FLrPlayerDisconnect( i );
|
---|
| 167 | continue;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 | //Just to know if we have started counting off the respawn
|
---|
[579] | 171 | if(PlayerList[i]->state != STATE_DEAD)
|
---|
| 172 | {
|
---|
| 173 | PlayerList[i]->state = STATE_DEAD;
|
---|
| 174 | PlayerList[i]->DeathTime = ONgGameState->GameTime;
|
---|
| 175 | if(i == client_slot)
|
---|
| 176 | {
|
---|
| 177 | ONrGameState_Timer_Start( "", TicksToRespawn );
|
---|
| 178 | }
|
---|
[583] | 179 |
|
---|
| 180 | if(server_started)
|
---|
| 181 | {
|
---|
| 182 | FLsPublic_Event( EV_KILLED, &i );
|
---|
| 183 | }
|
---|
| 184 |
|
---|
[579] | 185 | }
|
---|
| 186 |
|
---|
[583] | 187 | //Server respawning
|
---|
| 188 | if(server_started)
|
---|
[579] | 189 | {
|
---|
[583] | 190 | int Actions;
|
---|
| 191 | if(i == 0)
|
---|
| 192 | {
|
---|
| 193 | Actions = ONgGameState->Input.Current.Actions1;
|
---|
| 194 | }
|
---|
| 195 | else
|
---|
| 196 | {
|
---|
[584] | 197 | Actions = PlayerList[i]->InputFromClient.Actions1;
|
---|
[583] | 198 | }
|
---|
[579] | 199 |
|
---|
[583] | 200 | if(ONgGameState->GameTime - PlayerList[i]->DeathTime > TicksToRespawn &&
|
---|
| 201 | (Actions & (Action_Punch | Action_Kick)) )
|
---|
| 202 | {
|
---|
| 203 | FLrPlayerRespawn( i );
|
---|
| 204 |
|
---|
| 205 | FLsPublic_Event( EV_RESPAWN, &i );
|
---|
| 206 | }
|
---|
| 207 | else
|
---|
| 208 | {
|
---|
| 209 | continue;
|
---|
| 210 | }
|
---|
[579] | 211 | }
|
---|
[583] | 212 | else //clients?!
|
---|
[579] | 213 | {
|
---|
| 214 | continue;
|
---|
| 215 | }
|
---|
[583] | 216 | }
|
---|
[580] | 217 |
|
---|
[583] | 218 | PlayerList[i]->state = STATE_ALIVE;
|
---|
[580] | 219 |
|
---|
[586] | 220 | if( client_connected && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Class ) )
|
---|
[584] | 221 | {
|
---|
[586] | 222 | if(PlayerList[i]->Class)
|
---|
| 223 | {
|
---|
| 224 | ONrCharacter_SetCharacterClass( PlayerList[i]->Chr, PlayerList[i]->Class );
|
---|
| 225 | }
|
---|
| 226 | PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Class );
|
---|
| 227 | }
|
---|
| 228 |
|
---|
| 229 | if( client_connected && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Facing ) )
|
---|
| 230 | {
|
---|
[584] | 231 | PlayerList[i]->Chr->Facing = PlayerList[i]->Facings.Facing;
|
---|
[586] | 232 | if(i != client_slot)
|
---|
| 233 | {
|
---|
| 234 | PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->Facings.DesiredFacing;
|
---|
| 235 | }
|
---|
[584] | 236 | PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Facing );
|
---|
| 237 | }
|
---|
| 238 |
|
---|
[582] | 239 | if(Active_Player == 0) continue;
|
---|
[580] | 240 |
|
---|
[585] | 241 |
|
---|
[586] | 242 |
|
---|
| 243 | // Active_Player->PlayingFilm.Flags = 1;
|
---|
[585] | 244 |
|
---|
[586] | 245 | Active_Input = &(Active_Player->Input);
|
---|
[585] | 246 |
|
---|
[586] | 247 |
|
---|
| 248 | if( (server_started && i !=0) || !server_started )
|
---|
[582] | 249 | {
|
---|
[586] | 250 | Active_Input->Stop.Actions1 = ~PlayerList[i]->Input.Actions1 & Active_Input->Current.Actions1;
|
---|
| 251 | Active_Input->Stop.Actions2 = ~PlayerList[i]->Input.Actions2 & Active_Input->Current.Actions2;
|
---|
| 252 | Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & PlayerList[i]->Input.Actions1;
|
---|
| 253 | Active_Input->Start.Actions2 = ~Active_Input->Current.Actions2 & PlayerList[i]->Input.Actions2;
|
---|
[580] | 254 |
|
---|
[586] | 255 | Active_Input->Current.Actions1 = PlayerList[i]->Input.Actions1;
|
---|
| 256 | Active_Input->Current.Actions2 = PlayerList[i]->Input.Actions2;
|
---|
| 257 | Active_Input->Stopped.Actions1 = ~Active_Input->Current.Actions1;
|
---|
| 258 | Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2;
|
---|
| 259 | if(client_connected && i == client_slot)
|
---|
| 260 | {
|
---|
| 261 | Active_Input->MouseDeltaX = ONgGameState->Input.MouseDeltaX;
|
---|
| 262 | Active_Input->MouseDeltaY = ONgGameState->Input.MouseDeltaY;
|
---|
| 263 | }
|
---|
| 264 | else
|
---|
| 265 | {
|
---|
| 266 | Active_Input->MouseDeltaX = PlayerList[i]->Input.MouseDeltaX;
|
---|
| 267 | Active_Input->MouseDeltaY = PlayerList[i]->Input.MouseDeltaY;
|
---|
| 268 | }
|
---|
| 269 | }
|
---|
| 270 |
|
---|
| 271 | {
|
---|
| 272 | void* ConsoleAnimation = 0;
|
---|
| 273 | TMrInstance_GetDataPtr( 'TRAM', "KONOKOwatch_idle", &ConsoleAnimation);
|
---|
[580] | 274 |
|
---|
[586] | 275 | if(!Active_Player->IsInAir && Active_Input->Current.Actions1 & (Action_Console | Action_PauseScreen)
|
---|
| 276 | && !(PlayerList[i]->Chr->Flags & ONcCharacterFlag_BeingThrown)
|
---|
| 277 | && Active_Player->ThrowTargetCharacter != -1)
|
---|
| 278 | {
|
---|
| 279 | if(ConsoleAnimation && ConsoleAnimation != Active_Player->Animation)
|
---|
| 280 | {
|
---|
| 281 | ONrCharacter_SetAnimationExternal(PlayerList[i]->Chr, Active_Player->AnimationFromState, ConsoleAnimation, 10);
|
---|
| 282 | Player->Flags |= 0x00200000;
|
---|
| 283 | Active_Player->ForcedAnimationFrames = -1;// TRrAnimation_GetDuration(ConsoleAnimation);
|
---|
| 284 | }
|
---|
| 285 | }
|
---|
| 286 | else if(Active_Input->Stopped.Actions1 & (Action_Console | Action_PauseScreen) )
|
---|
| 287 | {
|
---|
| 288 | Active_Player->ForcedAnimationFrames = 0;
|
---|
| 289 | }
|
---|
[578] | 290 |
|
---|
[586] | 291 | }
|
---|
[578] | 292 |
|
---|
[586] | 293 | //Check for character switching requests
|
---|
| 294 | if(server_started && PlayerList[i]->Chr->Health != 0
|
---|
| 295 | && PlayerList[i]->InputFromClient.Actions1 & Action_Block)
|
---|
| 296 | {
|
---|
| 297 | if( PlayerList[i]->ShapeshiftCooldown < ONgGameState->GameTime)
|
---|
| 298 | {
|
---|
[588] | 299 | int error;
|
---|
[586] | 300 |
|
---|
[588] | 301 |
|
---|
| 302 |
|
---|
| 303 | ONCC *newClass;
|
---|
| 304 | short numClasses = (short)TMrInstance_GetTagCount('ONCC');
|
---|
| 305 | /*
|
---|
| 306 | if(Active_Player->Input.Start.Actions1 & Action_Block)
|
---|
| 307 | {
|
---|
| 308 | //This might not be getting hit. Find out why, eh?
|
---|
| 309 | PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15;
|
---|
| 310 | }
|
---|
| 311 | else
|
---|
| 312 | {
|
---|
| 313 | PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 5;
|
---|
| 314 | }
|
---|
| 315 | */
|
---|
| 316 |
|
---|
| 317 | PlayerList[i]->ShapeshiftCooldown = ONgGameState->GameTime + 15;
|
---|
| 318 |
|
---|
| 319 | if (PlayerList[i]->InputFromClient.Actions1 & Action_Crouch) {
|
---|
| 320 | Player->ONCCnumber += numClasses - 1;
|
---|
| 321 | }
|
---|
| 322 | else {
|
---|
| 323 | Player->ONCCnumber += 1;
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | if (numClasses > 0) {
|
---|
| 327 | Player->ONCCnumber = Player->ONCCnumber % numClasses;
|
---|
| 328 |
|
---|
| 329 | error = TMrInstance_GetDataPtr_ByNumber('ONCC', Player->ONCCnumber, &newClass);
|
---|
| 330 |
|
---|
| 331 | if ((newClass != NULL) && (!error)) {
|
---|
| 332 | ONrCharacter_SetCharacterClass(Player, newClass);
|
---|
| 333 | }
|
---|
| 334 | }
|
---|
| 335 |
|
---|
[586] | 336 | }
|
---|
[584] | 337 | }
|
---|
[586] | 338 | else
|
---|
| 339 | {
|
---|
| 340 | PlayerList[i]->ShapeshiftCooldown = 0;
|
---|
| 341 | }
|
---|
| 342 | if(client_connected) {
|
---|
[584] | 343 |
|
---|
[586] | 344 | if( DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Position) )
|
---|
| 345 | {
|
---|
| 346 | //Active_Player->PhyContext->Position = PlayerList[i]->Position;
|
---|
[584] | 347 |
|
---|
[586] | 348 | Active_Player->PhyContext->Position.X =
|
---|
| 349 | (PlayerList[i]->Position.X + Active_Player->PhyContext->Position.X) / 2;
|
---|
| 350 |
|
---|
| 351 | Active_Player->PhyContext->Position.Y =
|
---|
| 352 | (PlayerList[i]->Position.Y + Active_Player->PhyContext->Position.Y) / 2;
|
---|
| 353 |
|
---|
| 354 | Active_Player->PhyContext->Position.Z =
|
---|
| 355 | (PlayerList[i]->Position.Z + Active_Player->PhyContext->Position.Z) / 2;
|
---|
| 356 |
|
---|
| 357 | PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Position );
|
---|
| 358 | }
|
---|
| 359 |
|
---|
| 360 |
|
---|
| 361 |
|
---|
| 362 |
|
---|
[588] | 363 | if (!(Player->Flags & ONcCharacterFlag_BeingThrown) &&
|
---|
| 364 | DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation) && (PlayerList[i]->Animation))
|
---|
| 365 | {
|
---|
| 366 | // get a pointer to the animation
|
---|
| 367 |
|
---|
| 368 |
|
---|
| 369 | if (PlayerList[i]->Animation != Active_Player->Animation)
|
---|
| 370 | {
|
---|
| 371 |
|
---|
| 372 | ///////////////////////////////////
|
---|
| 373 | //TODO: Check age of animation
|
---|
| 374 | ///////////////////////////////////
|
---|
| 375 | // set the characters animation
|
---|
| 376 | /*ONrCharacter_SetAnimationInternal(Player,
|
---|
| 377 | Active_Player,
|
---|
| 378 | Active_Player->AnimationToState,
|
---|
| 379 | 0,
|
---|
| 380 | PlayerList[i]->Animation);*/
|
---|
| 381 | //ONrCharacter_NewAnimationHook(Player, Active_Player);
|
---|
| 382 | ONrCharacter_SetAnimationExternal(Player, TRrAnimation_GetFrom(PlayerList[i]->Animation), PlayerList[i]->Animation, 1);
|
---|
| 383 | //ONrCharacter_NewAnimationHook(Player, Active_Player);
|
---|
| 384 | }
|
---|
| 385 |
|
---|
| 386 |
|
---|
[586] | 387 | }
|
---|
[588] | 388 | PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Animation );
|
---|
| 389 |
|
---|
| 390 | //Disabled Frame syncing for now. In most cases it won't be useful.
|
---|
| 391 | if(0 && DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_FramePing) && PlayerList[i]->Frame != -1
|
---|
| 392 | //&& !DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Animation)
|
---|
| 393 | )
|
---|
| 394 | {
|
---|
| 395 | if( abs(PlayerList[i]->Frame - Active_Player->Frame) > 2 )
|
---|
| 396 | {
|
---|
| 397 | short AnimationLength;
|
---|
| 398 | AnimationLength = TRrAnimation_GetDuration(Active_Player->Animation);
|
---|
| 399 | if (PlayerList[i]->Frame >= AnimationLength)
|
---|
| 400 | {
|
---|
| 401 | Active_Player->Frame = AnimationLength - 1;
|
---|
| 402 | //Active_Player->Frame = 0;
|
---|
| 403 | }
|
---|
| 404 | else
|
---|
| 405 | {
|
---|
| 406 | Active_Player->Frame = PlayerList[i]->Frame;
|
---|
| 407 | }
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | }
|
---|
[586] | 411 | PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_FramePing );
|
---|
[584] | 412 |
|
---|
[586] | 413 | //Increment frame in case we were waiting
|
---|
| 414 | PlayerList[i]->Frame++;
|
---|
[584] | 415 |
|
---|
[588] | 416 | if (DoWeUpdateThis( PlayerList[i]->UpdateFlags, PFlag_Throws)
|
---|
| 417 | && PlayerList[i]->ThrowData.throwName[0] != 0)
|
---|
| 418 | {
|
---|
| 419 | if(PlayerList[PlayerList[i]->ThrowData.throwing])
|
---|
| 420 | {
|
---|
| 421 | short throwTarget = PlayerList[PlayerList[i]->ThrowData.throwing]->spawnnumber;
|
---|
| 422 | /*if ((throwTarget != Active_Player->throwing) &&
|
---|
| 423 | (PlayerList[i]->ThrowData.throwFrame < 10))*/
|
---|
| 424 | {
|
---|
| 425 | void *throw_animation;
|
---|
| 426 | ActiveCharacter* Target;
|
---|
| 427 | // get the animation
|
---|
| 428 |
|
---|
| 429 | TMrInstance_GetDataPtr(
|
---|
| 430 | 'TRAM',
|
---|
| 431 | PlayerList[i]->ThrowData.throwName,
|
---|
| 432 | &throw_animation);
|
---|
| 433 | //if (error) return;
|
---|
| 434 |
|
---|
| 435 | // set the throw target
|
---|
| 436 | Active_Player->ThrowTargetCharacter = &ONgGameState->CharacterStorage[throwTarget];
|
---|
| 437 | Target = ONrGetActiveCharacter(Active_Player->ThrowTargetCharacter);
|
---|
| 438 | //if (/*(Target->Animation != throw_animation) &&*/
|
---|
| 439 | // (OldAnimation != Animation) &&
|
---|
| 440 | // !(Active_Player->ThrowTargetCharacter->Flags & ONcCharacterFlag_BeingThrown))
|
---|
| 441 | // Target->thrownBy == -
|
---|
| 442 | {
|
---|
| 443 | // set the throw variables
|
---|
| 444 | Active_Player->targetThrow = throw_animation;
|
---|
| 445 | Active_Player->throwing = throwTarget;
|
---|
| 446 |
|
---|
| 447 | // run the throw
|
---|
| 448 | ONrCharacter_NewAnimationHook(Player, Active_Player);
|
---|
| 449 |
|
---|
| 450 | //if (Active_Player->ThrowTargetCharacter)
|
---|
| 451 | {
|
---|
| 452 | // Target->Frame += 2;
|
---|
| 453 | //DDrConsole_PrintF("Thrown by player %hi", Player->Number );
|
---|
| 454 | //DDrStartupMessage("Thrown by player %hi", Player->Number );
|
---|
| 455 | Target->thrownBy = Player->Number & 0x00ff;
|
---|
| 456 | }
|
---|
| 457 | }
|
---|
| 458 | }
|
---|
| 459 | }
|
---|
| 460 | else
|
---|
| 461 | {
|
---|
| 462 | DDrConsole_PrintF("Warning, tried to throw nonexistant player %hi",
|
---|
| 463 | PlayerList[i]->ThrowData.throwing );
|
---|
| 464 | }
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | //Always discard old throw data, even if it isnt applied
|
---|
[586] | 468 | PlayerList[i]->UpdateFlags &= ~( 1 << PFlag_Throws );
|
---|
[578] | 469 | }
|
---|
[581] | 470 |
|
---|
[582] | 471 |
|
---|
[578] | 472 | }
|
---|
[584] | 473 |
|
---|
[586] | 474 | if(server_started)
|
---|
| 475 | {
|
---|
| 476 | if(ONgGameState->GameTime % 120 == 0)
|
---|
| 477 | {
|
---|
| 478 | FLsPingAll();
|
---|
| 479 | }
|
---|
| 480 |
|
---|
| 481 | if(PlayerList[0])
|
---|
| 482 | {
|
---|
| 483 | PlayerList[0]->InputFromClient.Actions1 = ONgGameState->Input.Current.Actions1;
|
---|
| 484 | PlayerList[0]->InputFromClient.Actions2 = ONgGameState->Input.Current.Actions2;
|
---|
| 485 | PlayerList[0]->InputFromClient.MouseDeltaX = ONgGameState->Input.MouseDeltaX;
|
---|
| 486 | PlayerList[0]->InputFromClient.MouseDeltaY = ONgGameState->Input.MouseDeltaY;
|
---|
| 487 | }
|
---|
| 488 | FLsSendPlayerData();
|
---|
| 489 | }
|
---|
[582] | 490 | MultiplayerStatus.PleaseUpdateAllPlayers = 0;
|
---|
[578] | 491 | return ONgGameState;
|
---|
[579] | 492 | }
|
---|
| 493 |
|
---|
| 494 | void FLrPlayerDisconnect( int Player )
|
---|
| 495 | {
|
---|
| 496 | if(server_started)
|
---|
| 497 | {
|
---|
| 498 | //FLsPublic_Event(EV_DISCONNECT, &Player );
|
---|
[582] | 499 | MultiplayerStatus.PleaseUpdateAllPlayers = 1;
|
---|
[579] | 500 | }
|
---|
| 501 | //Kill off the character in another function, please
|
---|
| 502 | //ONrCharacter_SetHitPoints( PlayerList[Player]->Chr, 0);
|
---|
[580] | 503 |
|
---|
[579] | 504 | memset(PlayerList[Player], 0, sizeof(player_info));
|
---|
| 505 | PlayerList[Player] = 0;
|
---|
| 506 |
|
---|
| 507 |
|
---|
[580] | 508 |
|
---|
[579] | 509 | return;
|
---|
| 510 | }
|
---|
| 511 |
|
---|
| 512 | void FLrPlayerRespawn( int Player )
|
---|
| 513 | {
|
---|
| 514 | PlayerList[Player]->state = STATE_ALIVE;
|
---|
| 515 | ONrCorpse_Create(PlayerList[Player]->Chr);
|
---|
| 516 | ONrCharacter_SetHitPoints( PlayerList[Player]->Chr, PlayerList[Player]->Chr->MaxHealth );
|
---|
| 517 | }
|
---|
| 518 |
|
---|
| 519 |
|
---|
| 520 | void* ScoreboardInstance = 0;
|
---|
| 521 | void FLrRun_Scores()
|
---|
| 522 | {
|
---|
| 523 | if(client_connected || server_started)
|
---|
| 524 | {
|
---|
| 525 | if(!ScoreboardInstance){
|
---|
| 526 | void* TSFFTahoma;
|
---|
| 527 | TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);
|
---|
| 528 | TSrContext_New( TSFFTahoma, 7, 1, 1, 0, &ScoreboardInstance);
|
---|
| 529 | }
|
---|
| 530 | if(ScoreboardInstance){
|
---|
| 531 | const int white = 0x00FFFFFF;
|
---|
| 532 | const int green = 0x0000FF00;
|
---|
| 533 | const int red = 0x00FF0000;
|
---|
[586] | 534 | const int blue = 0x000000FF;
|
---|
[579] | 535 | int i;
|
---|
| 536 | char DrawString[255];
|
---|
| 537 | const int LineHeight = 15;
|
---|
[586] | 538 | IMtPoint2D DrawLocation = {25, 20};
|
---|
[579] | 539 | TSrContext_SetShade(ScoreboardInstance, white);
|
---|
| 540 | TSrContext_DrawText(ScoreboardInstance, "Oni Flatline build " __DATE__ " " __TIME__, 255, 0, &DrawLocation);
|
---|
[586] | 541 | TSrContext_SetShade(ScoreboardInstance, white);
|
---|
[579] | 542 | DrawLocation.y += LineHeight;
|
---|
[586] | 543 | DrawLocation.x = 25;
|
---|
[579] | 544 | TSrContext_DrawText(ScoreboardInstance, "Name", 255, 0, &DrawLocation);
|
---|
| 545 | DrawLocation.x += 150;
|
---|
| 546 | TSrContext_DrawText(ScoreboardInstance, "Score", 255, 0, &DrawLocation);
|
---|
[580] | 547 | DrawLocation.x += 50;
|
---|
| 548 | TSrContext_DrawText(ScoreboardInstance, "Ping", 255, 0, &DrawLocation);
|
---|
[579] | 549 | for(i = 0; i <MAX_PLAYERS; i++)
|
---|
| 550 | {
|
---|
[580] | 551 | if(PlayerList[i] == 0 || PlayerList[i]->Chr == 0) continue;
|
---|
[579] | 552 |
|
---|
[586] | 553 | DrawLocation.x = 10;
|
---|
[579] | 554 | DrawLocation.y += LineHeight;
|
---|
[580] | 555 |
|
---|
[586] | 556 | sprintf(DrawString, "%i.", i );
|
---|
| 557 | TSrContext_DrawText(ScoreboardInstance, DrawString, 255, 0, &DrawLocation);
|
---|
| 558 | DrawLocation.x += 15;
|
---|
| 559 |
|
---|
[580] | 560 | if(PlayerList[i]->Chr && PlayerList[i]->Chr->Health == 0)
|
---|
[579] | 561 | {
|
---|
| 562 | TSrContext_SetShade(ScoreboardInstance, red);
|
---|
| 563 | }
|
---|
| 564 | else if (i == client_slot)
|
---|
| 565 | {
|
---|
| 566 | TSrContext_SetShade(ScoreboardInstance, green);
|
---|
| 567 | }
|
---|
[583] | 568 | TSrContext_DrawText(ScoreboardInstance, PlayerList[i]->name, 255, 0, &DrawLocation);
|
---|
[579] | 569 | TSrContext_SetShade(ScoreboardInstance, white);
|
---|
| 570 | DrawLocation.x += 150;
|
---|
| 571 | sprintf(DrawString, "%i", PlayerList[i]->Chr->Damage);
|
---|
| 572 | TSrContext_DrawText(ScoreboardInstance, DrawString, 255, 0, &DrawLocation);
|
---|
[580] | 573 | DrawLocation.x += 50;
|
---|
[584] | 574 | sprintf(DrawString, "%i", PlayerList[i]->Ping);
|
---|
[580] | 575 | TSrContext_DrawText(ScoreboardInstance, DrawString, 255, 0, &DrawLocation);
|
---|
[579] | 576 | }
|
---|
| 577 | }
|
---|
| 578 | }
|
---|
| 579 | }
|
---|
[582] | 580 |
|
---|
| 581 | bool FlatlineInitialize()
|
---|
| 582 | {
|
---|
| 583 | memset( Players, 0, sizeof( player_info ) * MAX_PLAYERS );
|
---|
| 584 | memset( PlayerList, 0, 4 * MAX_PLAYERS );
|
---|
| 585 | memset( &MultiplayerStatus, 0, sizeof( multiplayer_status ));
|
---|
| 586 | return 1;
|
---|
| 587 | }
|
---|