Changeset 579


Ignore:
Timestamp:
Jan 13, 2011, 2:02:52 AM (14 years ago)
Author:
gumby
Message:

Finally back up to pre data loss standards

Location:
Daodan/MSVC
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • Daodan/MSVC/Daodan_Utility.c

    r578 r579  
    176176}
    177177
    178 void* ScoreboardInstance = 0;
    179 void FLrRun_Scores()
    180 {
    181 
    182         if(!ScoreboardInstance){
    183                 void* TSFFTahoma;
    184                 TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);
    185                 TSrContext_New( TSFFTahoma, 7, 1, 1,  0, &ScoreboardInstance);
    186         }
    187         if(ScoreboardInstance){
    188                 int white = 0x00FFFFFF;
    189                 IMtPoint2D DrawLocation = {20, 20};
    190                 TSrContext_SetShade(ScoreboardInstance, white);
    191                 TSrContext_DrawText(ScoreboardInstance, "Scores and crap", 255, 0, &DrawLocation);     
    192         }
    193 }
    194 
    195178void ONICALL DDrText_Hook()
    196179{
  • Daodan/MSVC/Flatline.c

    r578 r579  
    11#include "Flatline.h"
    22#include "Oni_Character.h"
     3#include "Flatline_Client.h"
    34#include "Flatline_Server.h"
     5#include "Flatline_Events.h"
    46//#include <sys/time.h>
    57#include <time.h>
     
    456458                        }
    457459                        break;
    458                        
     460                case FLATLINE_EVENT:
     461                        FLcEventHandler( packet.flatline_event.event_index, packet.flatline_event.intArray );
     462                        break;
    459463                default:
    460464                        DDrConsole_PrintF("Warning, recieved badly formed packet!");
     
    502506{
    503507        uint16_t i;
    504                 /*DDrConsole_PrintF("Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x",
    505                 ONgGameState->Input.Current.Actions1, ONgGameState->Input.Current.Actions2,
    506                 ONgGameState->Input.Start.Actions1,ONgGameState->Input.Start.Actions2,
    507                 ONgGameState->Input.Stop.Actions1, ONgGameState->Input.Stop.Actions2,
    508                 ONgGameState->Input.Stopped.Actions2, ONgGameState->Input.Stopped.Actions2
    509                 );
    510         */     
     508
    511509        ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters;
    512510        Active_Player->PhyContext->Rotation;
     
    514512        ONgGameState->PlayerCharacter->Position;
    515513
    516  
    517        
    518         /*
    519         if( ONgGameState->Input.MouseDeltaX != 0 || ONgGameState->Input.MouseDeltaY != 0 ||
    520                 ONgGameState->Input.field_8 != 0 || ONgGameState->Input.field_C != 0 )
    521 
    522         DDrConsole_PrintF("%f %f | %f %f",
    523                 ONgGameState->Input.MouseDeltaX , ONgGameState->Input.MouseDeltaY,
    524                 ONgGameState->Input.field_8, ONgGameState->Input.field_C);
    525 
    526                 */
    527         //if sprint timer is equal to 0, display 0
    528         //else if sprint timer is equal to -1, display -1
    529         //else display difference
    530         //good thing this is just quick an dirty debug stuff :)
    531 
    532         //basically it seems that if the difference is bigger than 15 frames, you cant dash. : /
    533        
    534 #ifndef SPAM_INPUT
    535514        if(client_connected)
    536515        {
     
    548527                //return ONgGameState;
    549528        }
    550 #endif
    551         //Testing drawing text to the screen...this failed. Will need to get it working eventually.
    552         if( TSrTest )
    553         {
    554 //              OniRectangle TextRect = { 128, 128, 256, 256 };
    555                 IMtPoint2D Point = {50, 50};
    556                 //TSrContext_DrawText(TSrTest, "Testing woohoo", 255, 0, &Point);
    557                 TSrContext_DrawText(TSrTest, "WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW", 255, 0, &Point);   
    558                
    559         }
     529
     530
    560531        if(!(server_started || client_connected)) return ONgGameState;
    561532
     
    566537                if(PlayerList[i] == 0) continue;
    567538               
    568                 //is this right?
     539               
    569540                Player = PlayerList[i]->Chr;
    570                 Active_Player = (void*)ONrGetActiveCharacter( PlayerList[i]->Chr);
     541                if( Player->Health == 0)
     542                {
     543                        int Actions;
     544                        const short TicksToRespawn = 3 * 60;
     545                        if(PlayerList[i]->state != STATE_DEAD)
     546                        {
     547                                PlayerList[i]->state = STATE_DEAD;
     548                                PlayerList[i]->DeathTime = ONgGameState->GameTime;
     549                                if(i == client_slot)
     550                                {
     551                                        ONrGameState_Timer_Start( "", TicksToRespawn  );
     552                                }
     553                        }
     554
     555                        if(server_started & i == 0)
     556                        {
     557                                Actions =  ONgGameState->Input.Current.Actions1;
     558                        }
     559                        else
     560                        {
     561                                Actions = PlayerList[i]->Actions1;
     562                        }
     563
     564                        if(PlayerList[i]->flags & PF_SCRIPTEDAI)
     565                        {
     566                                FLrPlayerDisconnect( i );
     567                        }
     568                        else if(ONgGameState->GameTime - PlayerList[i]->DeathTime < TicksToRespawn )
     569                        {
     570                                continue;
     571                        }
     572                        else if(Actions & (Action_Punch | Action_Kick))
     573                        {
     574                                FLrPlayerRespawn( i );
     575                        }
     576                        continue;
     577                               
     578                       
     579                }
     580
     581                Active_Player = ONrGetActiveCharacter( PlayerList[i]->Chr);
    571582               
    572583                if(Active_Player == 0) continue;
     
    576587                        flatline_packet data_out = {0};
    577588
    578                         //if( PlayerList[i]->Chr->Health == 0) PlayerList[i]->Chr->Health = PlayerList[i]->Chr->MaxHealth;
     589                       
    579590
    580591                        data_out.id = PLAYER_DATA;
     
    592603                        if(Active_Player->targetThrow)
    593604                        {
    594                                 data->throw_data.throwing = Active_Player->throwing;
     605                                data->throw_data.throwing = Players[Active_Player->throwing].list_slot;
    595606                                memcpy(data->throw_data.throwName, TMrInstance_GetInstanceName(Active_Player->targetThrow), 31);
    596607                                data->throw_data.throwFrame = ONrGetActiveCharacter(Active_Player->targetThrow)->Frame;
    597                                
    598                         }
    599                        
    600 
     608                        }
    601609                       
    602610                       
     
    631639                if( (server_started && i !=0)  || (!server_started/* && i != client_slot*/) )
    632640                {
    633                         //this just made sync even worse...
    634 #ifdef JITTER_FIX
    635                         input_struct * New_Input = &PlayerList[i]->MouseDeltaX;
    636                         input_struct * Cache_Input = &PlayerList[i]->CacheInput;
    637                         Active_Input->Stop.Actions1 = ~Cache_Input->Actions1 & Active_Input->Current.Actions1;
    638                         Active_Input->Stop.Actions2 = ~Cache_Input->Actions2 & Active_Input->Current.Actions2;
    639                         Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & Cache_Input->Actions1;
    640                         Active_Input->Start.Actions2 = ~Active_Input->Current.Actions2 & Cache_Input->Actions2;
    641                         Active_Input->Current.Actions1 = Cache_Input->Actions1;
    642                         Active_Input->Current.Actions2 = Cache_Input->Actions2;
    643                         Active_Input->Stopped.Actions1 = ~Active_Input->Current.Actions1;
    644                         Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2;
    645                         Active_Input->MouseDeltaX = Cache_Input->MouseDeltaX;
    646                         Active_Input->MouseDeltaY = Cache_Input->MouseDeltaY;
    647                         memcpy( Cache_Input, New_Input, sizeof(input_struct));
    648 #else
    649        
    650641                        Active_Input->Stop.Actions1 = ~PlayerList[i]->Actions1 & Active_Input->Current.Actions1;
    651642                        Active_Input->Stop.Actions2 = ~PlayerList[i]->Actions2 & Active_Input->Current.Actions2;
     
    659650                        Active_Input->MouseDeltaX = PlayerList[i]->MouseDeltaX;
    660651                        Active_Input->MouseDeltaY = PlayerList[i]->MouseDeltaY;
    661                         //DDrConsole_PrintF("Timer: %i", (Active_Player->SprintTimer != 0) ? (Active_Player->SprintTimer == -1) ? -1 : (ONgGameState->GameTime - Active_Player->SprintTimer) : 0);
    662 
    663                         //DDrConsole_PrintF("1E8 %u", ONgGameState->PlayerCharacter->field_1E8);
    664 /*
    665                         DDrConsole_PrintF("T %u | Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x",
    666                                 PlayerList[i]->LastInputTime,
    667                                 Active_Input->Current.Actions1, Active_Input->Current.Actions2,
    668                                 Active_Input->Start.Actions1,Active_Input->Start.Actions2,
    669                                 Active_Input->Stop.Actions1, Active_Input->Stop.Actions2,
    670                                 Active_Input->Stopped.Actions1, Active_Input->Stopped.Actions2
    671                 );
    672                 */
    673                        
    674                
    675 #endif
    676 
    677 #ifdef BETTER_SYNC
     652
     653
    678654                        if( !server_started && PlayerList[i]->player_data.Health != 0) {
    679655                                void* OldAnimation;
     
    763739                                if (PlayerList[i]->player_data.throw_data.throwName[0] != 0)
    764740                                {
    765                                         if ((pd->throw_data.throwing != 0xFFFF) &&
    766                                                 (pd->throw_data.throwing != Active_Player->throwing) &&
     741                                        pd->throw_data.throwing = PlayerList[pd->throw_data.throwing]->spawnnumber;
     742                                        if ((pd->throw_data.throwing != Active_Player->throwing) &&
    767743                                                (pd->throw_data.throwFrame < 10))
    768744                                        {
     
    801777
    802778                        }
    803 #endif
    804 
    805779                }
    806780        }
     
    808782        return ONgGameState;
    809783}
     784
     785void FLrPlayerDisconnect( int Player )
     786{
     787        if(server_started)
     788        {
     789                //FLsPublic_Event(EV_DISCONNECT, &Player );
     790        }
     791        //Kill off the character in another function, please
     792        //ONrCharacter_SetHitPoints(  PlayerList[Player]->Chr, 0);
     793       
     794        memset(PlayerList[Player], 0, sizeof(player_info));
     795        PlayerList[Player] = 0;
     796       
     797
     798
     799        return;
     800}
     801
     802void FLrPlayerRespawn( int Player )
     803{
     804        PlayerList[Player]->state = STATE_ALIVE;
     805        ONrCorpse_Create(PlayerList[Player]->Chr);
     806        ONrCharacter_SetHitPoints(  PlayerList[Player]->Chr, PlayerList[Player]->Chr->MaxHealth );
     807}
     808
     809
     810void* ScoreboardInstance = 0;
     811void FLrRun_Scores()
     812{
     813        if(client_connected || server_started)
     814        {
     815                if(!ScoreboardInstance){
     816                        void* TSFFTahoma;
     817                        TMrInstance_GetDataPtr( 'TSFF', "Tahoma", &TSFFTahoma);
     818                        TSrContext_New( TSFFTahoma, 7, 1, 1,  0, &ScoreboardInstance);
     819                }
     820                if(ScoreboardInstance){
     821                        const int white =       0x00FFFFFF;
     822                        const int green =       0x0000FF00;
     823                        const int red =         0x00FF0000;
     824                        int i;
     825                        char DrawString[255];
     826                        const int LineHeight = 15;
     827                        IMtPoint2D DrawLocation = {20, 20};
     828                        TSrContext_SetShade(ScoreboardInstance, white);
     829                        TSrContext_DrawText(ScoreboardInstance, "Oni Flatline build " __DATE__ " " __TIME__, 255, 0, &DrawLocation);
     830                        DrawLocation.y += LineHeight;
     831                        TSrContext_DrawText(ScoreboardInstance, "Name", 255, 0, &DrawLocation);
     832                        DrawLocation.x += 150;
     833                        TSrContext_DrawText(ScoreboardInstance, "Score", 255, 0, &DrawLocation);
     834                        for(i = 0; i <MAX_PLAYERS; i++)
     835                        {
     836                                if(PlayerList[i] == 0) continue;
     837
     838                                DrawLocation.x = 20;
     839                                DrawLocation.y += LineHeight;
     840                               
     841                                if(PlayerList[i]->Chr->Health == 0)
     842                                {
     843                                        TSrContext_SetShade(ScoreboardInstance, red);
     844                                }
     845                                else if (i == client_slot)
     846                                {
     847                                        TSrContext_SetShade(ScoreboardInstance, green);
     848                                }
     849                                TSrContext_DrawText(ScoreboardInstance, PlayerList[i]->Chr->Name, 255, 0, &DrawLocation);
     850                                TSrContext_SetShade(ScoreboardInstance, white);
     851                                DrawLocation.x += 150;
     852                                sprintf(DrawString, "%i", PlayerList[i]->Chr->Damage);
     853                                TSrContext_DrawText(ScoreboardInstance, DrawString, 255, 0, &DrawLocation);
     854
     855                        }
     856                }
     857        }
     858}
  • Daodan/MSVC/Flatline.h

    r578 r579  
    174174
    175175enum {
    176         NULL_PACKET, //
     176        NULL_PACKET, //Don't use. ;)
    177177        CONNECT_SEND,
    178178        CONNECT_REPLY,
     
    227227        uint16_t state;
    228228        int flags;
     229        int DeathTime;
    229230} player_info;
    230231
     
    250251extern char player_name[];
    251252void FLrRun_Scores();
    252 void PlayerDisconnect( int Player );
     253void FLrPlayerDisconnect( int Player );
     254void FLrPlayerRespawn( int Player );
    253255int FLrEvent_GetNumArgs( int eventIndex );
    254256#endif
  • Daodan/MSVC/Flatline_BSL.c

    r578 r579  
    128128uint16_t ONICALL kick(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
    129129{
    130         PlayerDisconnect(args[0].value_int32);
     130        FLrPlayerDisconnect(args[0].value_int32 - 1);
     131        FLsPublic_Event(EV_DISCONNECT, &args[0].value_int32);
    131132        return 0;
    132133}
  • Daodan/MSVC/Flatline_Server.c

    r578 r579  
    124124}
    125125
     126//FLsPublic_Event
    126127//Sends an event (door opening, player disconnecting, etc) to all players
    127128//Always make sure you send a pointer to this, even if it is just one arg. ;)
    128 void FLsPublic_Event( unsigned int eventIndex, int * args )
     129//Returns 0 because mixing C and assembly is stupid.
     130//If it is void the double door in State crashes. Probably stack corruption,
     131//I'm not sure exactly why.
     132int FLsPublic_Event( const unsigned int eventIndex, const int * args )
    129133{
    130134        int numArgs = FLrEvent_GetNumArgs( eventIndex );
     135        int ret;
    131136        flatline_packet eventPacket = {0};
    132137        eventPacket.id = FLATLINE_EVENT;
    133138        eventPacket.flatline_event.event_index = eventIndex;
    134         memcpy( eventPacket.flatline_event.intArray, args, sizeof(int) * numArgs );
    135         UDPServer_SendToAll( &eventPacket, sizeof(int) * (numArgs + 1) + FLATLINE_HEADER );
     139        ret = memcpy( eventPacket.flatline_event.intArray, args, sizeof(int) * numArgs );
     140        ret = UDPServer_SendToAll( &eventPacket, sizeof(int) * (numArgs + 1) + FLATLINE_HEADER );
     141        return 0;
    136142}
    137143
    138 void PlayerDisconnect( int Player )
    139 {
    140         FLsPublic_Event(EV_DISCONNECT, &Player );
    141         memset(PlayerList[Player], 0, sizeof(player_info));
    142         return;
    143 }
  • Daodan/MSVC/Flatline_Server.h

    r573 r579  
    99extern uint16_t max_connections;
    1010player_info* FLrServer_AddPlayer(int ip, char* name, bool is_server, bool is_bot);
    11 void FLsPublic_Event( unsigned int eventIndex, int * args);
     11int FLsPublic_Event( const unsigned int eventIndex, const int * args);
    1212
    1313void FLrServer_Initialize();
  • Daodan/MSVC/Oni_Symbols.c

    r578 r579  
    184184DefFunc( OBJrConsole_OnActivate                                 , 0x004C0880 );
    185185DefFunc( ONrCharacter_SetAnimationExternal              , 0x004EB340 );
     186DefFunc( ONrGameState_Timer_Start                               , 0x004FD370 );
    186187#define DefVar(type, name, address) //type* _##name = (type*)address
    187188
  • Daodan/MSVC/Oni_Symbols.h

    r578 r579  
    124124        void            *ioTextContext,
    125125        uint32_t        inShade);
    126 
     126typedef void (* _ONrGameState_Timer_Start)( char* function, int time );
    127127typedef uint16_t ( *_TRrAnimation_GetDuration)(void* Animation);
    128128typedef uint16_t ( *_TRrAnimation_GetTo)(void* Animation);
     
    170170ExtFunc(TRrAnimation_GetFrom);
    171171ExtFunc(TRrAnimation_GetTo);
    172 
     172ExtFunc(ONrGameState_Timer_Start);
    173173extern _UUrMachineTime_High UUrMachineTime_High;
    174174extern _UUrMachineTime_High_Frequency UUrMachineTime_High_Frequency;
Note: See TracChangeset for help on using the changeset viewer.