Changeset 568


Ignore:
Timestamp:
Jun 30, 2010, 6:25:00 AM (14 years ago)
Author:
gumby
Message:

Updates

Location:
Daodan/MSVC
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Daodan/MSVC/Daodan_BSL.c

    r567 r568  
    475475        else index = args[0].value_int32;
    476476
    477         Chr = ONgGameState->CharacterStorage;
    478         Active = ONrGetActiveCharacter(&Chr[index]);
     477        Chr = &(ONgGameState->CharacterStorage[index]);
     478        Active = ONrGetActiveCharacter(Chr);
    479479        if (!Active) return 1;
    480480
     
    819819        SLrScript_Command_Register_ReturnType("d_maxhealth","Gets or sets a character's maximum health", "[ai_name:string | script_id:int] [newmaxhealth:int] [scalehealth:bool]", sl_str32, bsl_maxhealth);
    820820        SLrScript_Command_Register_ReturnType("d_powerup","Gets or sets a character's powerups", "[ai_name:string | script_id:int] powerup:string", sl_int32, bsl_powerup);
     821        //d_holdkey is broken!
    821822        SLrScript_Command_Register_ReturnType("d_holdkey","Makes a character hold a key", "[ai_name:string | script_id:int] frames:int keys:string", sl_int32, bsl_holdkey);
    822823        SLrScript_Command_Register_ReturnType("d_isheld","Checks if player is holding a key", "[ai_name:string | script_id:int] [keys:string]", sl_int32, bsl_isheld);
  • Daodan/MSVC/Flatline.c

    r567 r568  
    1515};
    1616
     17#define BETTER_SYNC
     18
     19void DoRareSync( short Player, sockaddr_in * sender )
     20{
     21        flatline_packet sync = {0};     
     22
     23        if (Player > max_connections || !PlayerList[ Player ] ) return;
     24       
     25                       
     26//      DDrConsole_PrintF( "Sending sync data for player %i, new index %u", Player, PlayerList[ Player ]->rare_sync_index);
     27        sender->sin_addr.S_un.S_addr = htonl(sender->sin_addr.S_un.S_addr);
     28        sync.id = RARE_SYNC_DATA;
     29        sprintf( sync.rare_sync_data.Class, TMrInstance_GetInstanceName( PlayerList[ Player ]->Chr->ONCC ) );
     30        //using ->Inventory instead of ->Chr->Inventory to keep the index and Inventory in sync, just in case.
     31        memcpy( &(sync.rare_sync_data.Inventory), &(PlayerList[ Player ]->Inventory), sizeof(Inventory) );
     32        //WEAPONS ARE DISABLED. Why? Pain in the arse to sync.
     33        sync.rare_sync_data.Inventory.Weapons[0] = NULL;
     34        sync.rare_sync_data.Inventory.Weapons[1] = NULL;
     35        sync.rare_sync_data.Inventory.Weapons[2] = NULL;
     36        sync.rare_sync_data.PlayerNum = Player;
     37        sync.rare_sync_data.index = PlayerList[ Player ]->rare_sync_index;
     38        NetTCPServer_Send( sender, (char*)&sync, sizeof(rare_sync_data) + FLATLINE_HEADER );
     39}
     40
    1741bool FLrServer_PacketCallback(char* data, int datalen, int from)
    1842{
     
    7296                                memset(Char, 0, sizeof(CharacterObject));
    7397                                Char->Header.Type = 'CHAR';
    74                                 Char->OSD.Options = chr_dontaim | chr_unkillable;
     98                                Char->OSD.Options = chr_dontaim;
    7599                                for(j = 0; j < max_connections; j++) {
    76100                                        if(PlayerList[j] != 0) {
     
    170194                                PlayerList[i]->MouseDeltaX = packet_input->MouseDeltaX;
    171195                                PlayerList[i]->MouseDeltaY = packet_input->MouseDeltaY;
    172 
     196                                PlayerList[i]->LastInputTime = packet_input->Time;
    173197
    174198                                break;
    175199                        }
     200                case RARE_SYNC_DATA_REQUEST:
     201                        DoRareSync( packet->sync_request , &sender);
     202                        break;
    176203                default:
    177204                        DDrConsole_PrintF("Warning, recieved badly formed packet!");
     
    226253
    227254                                        client_slot = ((connect_reply*)packet->data)->player_slot;
     255
     256                                        PlayerList[client_slot] = Players+client_slot;
     257                                        PlayerList[client_slot]->Chr = ONgGameState->PlayerCharacter;
     258
     259                                        DDrConsole_PrintColored("Connection successful!",0,green, grey);
    228260                                       
    229                         PlayerList[client_slot] = Players+client_slot;
    230                         PlayerList[client_slot]->Chr = ONgGameState->PlayerCharacter;
    231                        
    232                        
    233 
    234                                         DDrConsole_PrintColored("Connection successful!",0,green, grey);
     261                                        //disable local input.
     262                                        DDrPatch_NOOP(0x004FA929, 5 + 6 + 5);
     263                                       
    235264                                        //DDrConsole_PrintF("Slot %i",  ((connect_reply*)packet)->player_slot);
    236265                                        break;
     
    322351                        else {
    323352                                ONrGameState_NewCharacter(Char, NULL, NULL, &chr_index);
     353                                ONgGameState->CharacterStorage[chr_index].field_1E8 = 0;
    324354                                PlayerList[packet.new_player.Playernumber] = &Players[chr_index];
    325355                                Players[chr_index].Chr = &(ONgGameState->CharacterStorage[chr_index]);
    326356                                Players[chr_index].Chr->Flags &= 0xFFBFFFFF;
     357                                Players[chr_index].spawnnumber = chr_index;
    327358                                DDrConsole_PrintF("Spawning player %s, class %s, slot  %i", ((new_player*)(packet.data))->Character.OSD.Name, ((new_player*)(packet.data))->Character.OSD.Class,chr_index) ;
    328359                        }
     
    341372                        if( !PlayerList[i] ) break;
    342373                        //PlayerList[i]->Chr = ((GameState *)ONgGameState)->CharacterStorage;
    343                        
     374#ifndef BETTER_SYNC
    344375                        PlayerList[i]->Chr->Health = data->Health;
    345376                        PlayerList[i]->Chr->MaxHealth = data->MaxHealth;
     
    359390
    360391                        Active->PhyContext->Position = data->Position;
     392#else
     393                        PlayerList[i]->Actions1 = data->Inputs.Actions1;
     394                        PlayerList[i]->Actions2 = data->Inputs.Actions2;
     395                        PlayerList[i]->MouseDeltaX = data->Inputs.MouseDeltaX;
     396                        PlayerList[i]->MouseDeltaY = data->Inputs.MouseDeltaY;
     397                        memcpy( &(PlayerList[i]->player_data), data, sizeof(player_data) );
     398#endif
     399                        if( !server_started && data->rare_sync_index > PlayerList[i]->rare_sync_index )
     400                        {
     401                                        int sent_bytes;
     402                                        flatline_packet sync_request = {0};
     403                                        sync_request.id = RARE_SYNC_DATA_REQUEST;
     404                                        sync_request.sync_request = i;
     405                                        DDrConsole_PrintF( "Requesting sync data for player %i, old index %u", i, PlayerList[i]->rare_sync_index);
     406                                        sent_bytes = NetUDPSocket_Send(client_sock,(sockaddr *) &address, (char*)&sync_request, FLATLINE_HEADER + sizeof(int) );
     407                        }
     408
    361409
    362410#if 0           
     
    389437                        break;
    390438                        }
     439                case RARE_SYNC_DATA:
     440                        if(1) {
     441                        sl_arg hax[2];
     442                        int dontuse;
     443                        uint16_t i = packet.rare_sync_data.PlayerNum;
     444                                               
     445                        if (i > max_connections) break;
     446                        if( !PlayerList[i] ) break;
     447
     448                        //WEAPONS ARE DISABLED. Why? Pain in the arse to sync.
     449                        packet.rare_sync_data.Inventory.Weapons[0] = NULL;
     450                        packet.rare_sync_data.Inventory.Weapons[1] = NULL;
     451                        packet.rare_sync_data.Inventory.Weapons[2] = NULL;
     452//                      TMrInstance_GetDataPtr( 'ONCC', packet.rare_sync_data.Class, PlayerList[ i ]->Chr->ONCC );
     453                       
     454                        //add the target character
     455                        hax[0].type = sl_int32;
     456                        hax[0].value_int32 = PlayerList[ packet.rare_sync_data.PlayerNum ]->spawnnumber;
     457
     458                        //add the new class
     459                        //fix this later so we cant buffer overflow :O
     460                        hax[1].type = sl_str32;
     461                        hax[1].value_str32 = packet.rare_sync_data.Class;
     462                       
     463                        //we are directly calling a bsl function instead of using the normal method for two reasons
     464                        //1. it has all the checking built in
     465                        iSetCharacterClass( 0, 2, hax, &dontuse, &dontuse, hax );
     466                        //DDrConsole_PrintF( "Recieved sync data for player %i, class %s, old index %u, new index %u", i, packet.rare_sync_data.Class, PlayerList[i]->rare_sync_index, packet.rare_sync_data.index);
     467                        memcpy( &(PlayerList[ i ]->Chr->Inventory), &(packet.rare_sync_data.Inventory), sizeof(Inventory ));
     468
     469                        PlayerList[i]->rare_sync_index = packet.rare_sync_data.index;
     470                        }
     471                        break;
     472                       
    391473                default:
    392474                        DDrConsole_PrintF("Warning, recieved badly formed packet!");
     
    402484}
    403485
    404 //UDPServer_SendToAll
    405 //Sends a packet to all the clients currently connected.
    406 //Returns the number of players sent to.
    407 int UDPServer_SendToAll(void* packet, int size) {
    408         int j;
    409         int players = 0;
    410         sockaddr_in address;
    411         memset(&address, 0, sizeof(sockaddr_in));
    412         address.sin_family = AF_INET;
    413         address.sin_addr.s_addr = htonl(INADDR_ANY);
    414         address.sin_port = htons(27777);
    415         for(j = 0; j < max_connections; j++) {
    416                 if (PlayerList[j] != 0 && PlayerList[j]->ip && (PlayerList[j]->ip != inet_addr("127.0.0.1"))) {
    417                         int sent_bytes;
    418                         address.sin_addr.s_addr = htonl(PlayerList[j]->ip);//*((struct in_addr*)(int*)&(Players[j].ip));               
    419                         sent_bytes = NetUDPServer_Send((sockaddr *) &address, (char*)packet, size);
    420                         if(sent_bytes == SOCKET_ERROR) NetCatchError();
    421                         else players++;
    422                 }
    423         }
    424         return players;
    425 }
    426 
     486//wtf, this needs cleaned up...
    427487player_info *FLr_FindEmptySlot() {
    428488        int j;
     
    450510void * ONICALL FLrInput_Update_Keys(void)
    451511{
    452                 uint16_t i;
     512        uint16_t i;
     513        /*DDrConsole_PrintF("Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x",
     514                ONgGameState->Input.Current.Actions1, ONgGameState->Input.Current.Actions2,
     515                ONgGameState->Input.Start.Actions1,ONgGameState->Input.Start.Actions2,
     516                ONgGameState->Input.Stop.Actions1, ONgGameState->Input.Stop.Actions2,
     517                ONgGameState->Input.Stopped.Actions2, ONgGameState->Input.Stopped.Actions2
     518                );
     519        */     
     520        ActiveCharacter * Active_Player = ONgGameState->ActiveCharacters;
     521       
     522        //if sprint timer is equal to 0, display 0
     523        //else if sprint timer is equal to -1, display -1
     524        //else display difference
     525        //good thing this is just quick an dirty debug stuff :)
     526
     527        //basically it seems that if the difference is bigger than 15 frames, you cant dash. : /
     528       
    453529#ifndef SPAM_INPUT
    454530        if(client_connected)
     
    457533                flatline_packet input_packet = {0};
    458534                input_packet.id = PLAYER_INPUT;
    459                
     535                input_packet.input_struct.Time = ONgGameState->GameTime;
    460536                input_packet.input_struct.Actions1 = ((GameState*)(ONgGameState))->Input.Current.Actions1;
    461537                input_packet.input_struct.Actions2 = ((GameState*)(ONgGameState))->Input.Current.Actions2;
     
    469545#endif
    470546        //Testing drawing text to the screen...this failed. Will need to get it working eventually.
    471         if( TSrTest ) 
     547        if( TSrTest )
    472548        {
    473549        OniRectangle TextRect = { 20, 20, 50, 50 };
     
    481557                if(PlayerList[i] == 0) continue;
    482558               
    483                 Active_Player = (void*)ONrGetActiveCharacter(PlayerList[i]->Chr);
     559                //is this right?
     560                Active_Player = (void*)ONrGetActiveCharacter( PlayerList[i]->Chr);
    484561       
    485562                if(Active_Player == 0) continue;
     
    499576                        data->DesiredFacing = PlayerList[i]->Chr->DesiredFacing;
    500577                        data->CosmeticFacing = PlayerList[i]->Chr->CosmeticFacing;
     578                        data->Position = Active_Player->PhyContext->Position;
     579                       
     580                        if( PlayerList[i]->OldClass != PlayerList[i]->Chr->ONCC || memcmp( &(PlayerList[i]->Inventory), &(PlayerList[i]->Chr->Inventory), sizeof(Inventory) ) )
     581                        {
     582                                PlayerList[i]->OldClass = PlayerList[i]->Chr->ONCC;
     583                                memcpy( &(PlayerList[i]->Inventory), &(PlayerList[i]->Chr->Inventory), sizeof(Inventory) );
     584                                PlayerList[i]->rare_sync_index++;
     585
     586                        }
     587                       
     588                        data->rare_sync_index = PlayerList[i]->rare_sync_index;
    501589                       
    502590#if 0
     
    531619                                data->Inputs.Actions2 = PlayerList[i]->Actions2;
    532620                        }
     621                        memcpy( &(PlayerList[i]->player_data), data, sizeof(player_data) );
     622                       
    533623                        UDPServer_SendToAll(&data_out, sizeof(player_data) + FLATLINE_HEADER);
    534624                }
    535625               
    536                 if( (server_started && i !=0) || (!server_started && i != client_slot)) {
     626                if( (server_started && i !=0)  || (!server_started/* && i != client_slot*/) )
     627                {
     628                        //this just made sync even worse....maybe keystrokes are actually _behind_
     629                        //
     630                        //
     631#ifdef JITTER_FIX
     632                        input_struct * New_Input = &PlayerList[i]->MouseDeltaX;
     633                        input_struct * Cache_Input = &PlayerList[i]->CacheInput;
     634                        Active_Input->Stop.Actions1 = ~Cache_Input->Actions1 & Active_Input->Current.Actions1;
     635                        Active_Input->Stop.Actions2 = ~Cache_Input->Actions2 & Active_Input->Current.Actions2;
     636                        Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & Cache_Input->Actions1;
     637                        Active_Input->Start.Actions2 = ~Active_Input->Current.Actions2 & Cache_Input->Actions2;
     638                        Active_Input->Current.Actions1 = Cache_Input->Actions1;
     639                        Active_Input->Current.Actions2 = Cache_Input->Actions2;
     640                        Active_Input->Stopped.Actions1 = ~Active_Input->Current.Actions1;
     641                        Active_Input->Stopped.Actions2 = ~Active_Input->Current.Actions2;
     642                        Active_Input->MouseDeltaX = Cache_Input->MouseDeltaX;
     643                        Active_Input->MouseDeltaY = Cache_Input->MouseDeltaY;
     644                        memcpy( Cache_Input, New_Input, sizeof(input_struct));
     645#else
     646       
    537647                        Active_Input->Stop.Actions1 = ~PlayerList[i]->Actions1 & Active_Input->Current.Actions1;
    538648                        Active_Input->Stop.Actions2 = ~PlayerList[i]->Actions2 & Active_Input->Current.Actions2;
    539649                        Active_Input->Start.Actions1 = ~Active_Input->Current.Actions1 & PlayerList[i]->Actions1;
    540650                        Active_Input->Start.Actions2 = ~Active_Input->Current.Actions2 & PlayerList[i]->Actions2;
     651                       
    541652                        Active_Input->Current.Actions1 = PlayerList[i]->Actions1;
    542653                        Active_Input->Current.Actions2 = PlayerList[i]->Actions2;
     
    545656                        Active_Input->MouseDeltaX = PlayerList[i]->MouseDeltaX;
    546657                        Active_Input->MouseDeltaY = PlayerList[i]->MouseDeltaY;
     658                        DDrConsole_PrintF("Timer: %i", (Active_Player->SprintTimer != 0) ? (Active_Player->SprintTimer == -1) ? -1 : (ONgGameState->GameTime - Active_Player->SprintTimer) : 0);
     659
     660                        //DDrConsole_PrintF("1E8 %u", ONgGameState->PlayerCharacter->field_1E8);
     661/*
     662                        DDrConsole_PrintF("T %u | Current: %x %x | Start: %x %x | Stop: %x %x | Stopped %x %x",
     663                                PlayerList[i]->LastInputTime,
     664                                Active_Input->Current.Actions1, Active_Input->Current.Actions2,
     665                                Active_Input->Start.Actions1,Active_Input->Start.Actions2,
     666                                Active_Input->Stop.Actions1, Active_Input->Stop.Actions2,
     667                                Active_Input->Stopped.Actions1, Active_Input->Stopped.Actions2
     668                );
     669                */
     670                       
     671               
     672#endif
     673
     674#ifdef BETTER_SYNC
     675                        if( !server_started && PlayerList[i]->player_data.Health != 0) {
     676                                PlayerList[i]->Chr->Health = PlayerList[i]->player_data.Health;
     677                                PlayerList[i]->Chr->MaxHealth = PlayerList[i]->player_data.MaxHealth;
     678                                PlayerList[i]->Chr->Position = PlayerList[i]->player_data.Position;
     679                                PlayerList[i]->Chr->Location = PlayerList[i]->player_data.Location;
     680                                PlayerList[i]->Chr->LastPosition = PlayerList[i]->player_data.LastPosition;
     681                                PlayerList[i]->Chr->Facing = PlayerList[i]->player_data.Facing;
     682                                PlayerList[i]->Chr->DesiredFacing = PlayerList[i]->player_data.DesiredFacing;
     683                                PlayerList[i]->Chr->CosmeticFacing = PlayerList[i]->player_data.CosmeticFacing;
     684                                PlayerList[i]->Actions1 = PlayerList[i]->player_data.Inputs.Actions1;
     685                                PlayerList[i]->Actions2 = PlayerList[i]->player_data.Inputs.Actions2;
     686                                PlayerList[i]->MouseDeltaX = PlayerList[i]->player_data.Inputs.MouseDeltaX;
     687                                PlayerList[i]->MouseDeltaY = PlayerList[i]->player_data.Inputs.MouseDeltaY;
     688                                Active_Player->PhyContext->Position = PlayerList[i]->player_data.Position;
     689                        }
     690#endif
     691
    547692                }
    548693        }
     694
     695        //Make the current controls match the sent controls, now that we have sent them off and everything is synced.
     696        //No, don't do it to the direct input, it breaks stuff.
     697        //Need to disable the function that puts game input onto characters because we are doing it directly.
     698        /*
     699        if( !server_started )
     700        {
     701                ONgGameState->Input.MouseDeltaX = PlayerList[client_slot]->MouseDeltaX;
     702                ONgGameState->Input.MouseDeltaY = PlayerList[client_slot]->MouseDeltaY;
     703                ONgGameState->Input.Current.Actions1 = PlayerList[client_slot]->Actions1;
     704                ONgGameState->Input.Current.Actions2 = PlayerList[client_slot]->Actions2;
     705        }
     706        */
     707       
    549708        return ONgGameState;
    550709}
  • Daodan/MSVC/Flatline.h

    r567 r568  
    6565DWORD WINAPI StartClient(void* lol);
    6666
    67 //oh snap, I just realized this is rossy's version of flatline_packet. :|
    68 typedef struct {
    69         char signature[8];
    70         uint16_t protocol_version;
    71         char data[0];                           //data[0] doesn't work well with simple casts, btw. If you allocate enough space for a handshake_packet
    72 } handshake_packet;                             //there won't be enough room for data. You would have to manually manage the memory (ew)
    7367
    7468//initial connection
     
    9892} new_player;
    9993
    100 extern int update_rate;
     94//extern int update_rate;
    10195
    10296typedef struct {
     
    10599        uint32_t Actions1;
    106100        uint32_t Actions2;
     101        unsigned int Time;
    107102} input_struct;
    108103
     
    123118        uint32_t MaxHealth;
    124119        input_struct Inputs;
     120        int rare_sync_index;
     121        //__int16 Varient;
    125122#if 0
    126123        uint16_t Frame;
     
    144141} player_data;
    145142
     143//todo, move health in...
     144typedef struct {
     145        short unsigned int PlayerNum;
     146        unsigned int index;
     147        Inventory Inventory;
     148        char Class[32];
     149} rare_sync_data;
     150
    146151//used for storing data about each player
    147152typedef struct {
     
    158163                server_status   server_status;
    159164                player_data             player_data;
     165                rare_sync_data  rare_sync_data;
     166                uint16_t                sync_request;
    160167        };
    161168} flatline_packet;
    162 #define FLATLINE_HEADER sizeof(flatline_packet)-sizeof(char)*1080
     169#define FLATLINE_HEADER (sizeof(flatline_packet)-sizeof(char)*1080)
    163170//#define FLATLINE_PACKET_SIZE sizeof(flatline_packet)
    164171
     
    179186        PLAYER_INPUT,
    180187        PLAYER_DATA,
     188        RARE_SYNC_DATA,
     189        RARE_SYNC_DATA_REQUEST,
    181190};
    182191
     
    184193typedef struct {
    185194        int      ip;
    186         char name[32];
     195        char name[32]; 
    187196        char country[2];
    188197        Character* Chr;
    189198        uint16_t spawnnumber;
    190199        uint16_t list_slot;
     200
     201        float MouseDeltaX;
     202        float MouseDeltaY;
    191203        uint32_t Actions1;
    192204        uint32_t Actions2;
    193         float MouseDeltaX;
    194         float MouseDeltaY;
     205        unsigned int LastInputTime;
     206        input_struct CacheInput;
     207
     208        player_data player_data;
     209
     210        unsigned int rare_sync_index;
     211        void* OldClass;
     212        Inventory Inventory;
    195213} player_info;
    196214
  • Daodan/MSVC/Flatline_BSL.c

    r567 r568  
    114114        return 0;
    115115}
    116 
    117 
     116uint16_t ONICALL addfake(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret)
     117{
     118        player_info * info;
     119info = FLrServer_AddPlayer( 0, "Fake", 0 );
     120info->Actions1 = Action_Forward;
     121return 0;
     122}
    118123void SLrFlatline_Initialize() {
    119124       
    120         DDrPatch_MakeCall(OniExe + 0x000FA88B, FLrInput_Update_Keys);
     125        DDrPatch_MakeCall(0x004FA88B, FLrInput_Update_Keys);
     126       
    121127        SLrGlobalVariable_Register_Int32("skip", "skips", &(((GameState*)ONgGameState)->field_40) );
    122128        SLrScript_Command_Register_ReturnType("connect","Connects to a server", "ip:string", sl_void, connect_to_server);
    123129        SLrScript_Command_Register_Void("host","Starts a server", "", start_server);
    124130        SLrScript_Command_Register_Void("msg","Sends a message", "", send_message);
    125         SLrScript_Command_Register_Void("name","changes your name", "name:str", change_name);
     131        SLrScript_Command_Register_ReturnType("name","changes your name", "name:str", sl_void, change_name);
    126132        SLrScript_Command_Register_Void("status","shows the connection status", "", status);
    127133        SLrGlobalVariable_Register_String("country", "Your Multiplayer country", player_name);
    128        
     134        SLrScript_Command_Register_ReturnType("addfakeclient","adds a fake client", "", sl_void, addfake);
    129135}
  • Daodan/MSVC/Flatline_Server.c

    r567 r568  
    5353                if(!is_server) {
    5454                        ONrGameState_NewCharacter(Char, NULL, NULL, &(player_slot));
     55                        //move this to a set up characters function...
     56                        ONgGameState->CharacterStorage[player_slot].field_1E8 = 0;
     57
    5558                        PlayerList[playerlist_slot] = Players+player_slot;
     59                        PlayerList[playerlist_slot]->spawnnumber = player_slot;
    5660                        PlayerList[playerlist_slot]->Chr = &((Character *)(((GameState * )(ONgGameState))->CharacterStorage))[player_slot];
    57                         PlayerList[playerlist_slot]->Chr->Flags = chr_dontaim | chr_unkillable; //&= 0xFFBFFFFF; //WTF
     61//                      PlayerList[playerlist_slot]->Chr->Flags = chr_dontaim | chr_unkillable; //&= 0xFFBFFFFF; //WTF
     62                        PlayerList[playerlist_slot]->Chr->Flags &= 0xFFBFFFFF; //WTF
    5863                        sprintf(PlayerList[playerlist_slot]->Chr->Name, "%.31s", name);         
    5964                        UDPServer_SendToAll( (char*)&new_char, sizeof(new_player) + FLATLINE_HEADER );
     
    7883void FLrServer_Initialize(){
    7984        FLrServer_AddPlayer(inet_addr("127.0.0.1"), "host", 1);
     85}
    8086
    81 
     87//UDPServer_SendToAll
     88//Sends a packet to all the clients currently connected.
     89//Returns the number of players sent to.
     90int UDPServer_SendToAll(void* packet, int size) {
     91        int j;
     92        int players = 0;
     93        sockaddr_in address;
     94        memset(&address, 0, sizeof(sockaddr_in));
     95        address.sin_family = AF_INET;
     96        address.sin_addr.s_addr = htonl(INADDR_ANY);
     97        address.sin_port = htons(27777);
     98        for(j = 0; j < max_connections; j++) {
     99                if (PlayerList[j] != 0 && PlayerList[j]->ip && (PlayerList[j]->ip != inet_addr("127.0.0.1"))) {
     100                        int sent_bytes;
     101                        address.sin_addr.s_addr = htonl(PlayerList[j]->ip);//*((struct in_addr*)(int*)&(Players[j].ip));               
     102                        sent_bytes = NetUDPServer_Send((sockaddr *) &address, (char*)packet, size);
     103                        if(sent_bytes == SOCKET_ERROR) NetCatchError();
     104                        else players++;
     105                }
     106        }
     107        return players;
    82108}
  • Daodan/MSVC/Oni_GameState.h

    r567 r568  
    479479} AttachedParticle;
    480480
     481
     482typedef struct
     483{
     484  __int16 Index;
     485  __int16 Flags;
     486  int Class;
     487  int Character;
     488  Matrix4x3 Matrix;
     489  int PhyContext;
     490  int Facing;
     491  __int16 FadeTimer;
     492  __int16 TimeToFade;
     493  int CreationTime;
     494  __int16 ShotDelay1;
     495  __int16 ShotDelay2;
     496  __int16 PauseBeforeReload;
     497  __int16 PauseAfterReload;
     498  __int16 ActiveFireModeLength;
     499  __int16 AmmoCount;
     500  __int16 field_58;
     501  __int16 FiringDelays[16];
     502  char gap_7a[2];
     503  int ParticleInstances[16];
     504  int field_BC[16];
     505  int field_FC;
     506  int DodgeFiringSpreadPtr;
     507  int field_104;
     508  int field_108;
     509  int field_10C;
     510  char gap_110[20];
     511  Vector3 Center;
     512  int NodeList[16];
     513} Weapon;
     514
    481515typedef struct { //Inventory
    482         int32_t Weapons[3];
     516        Weapon* Weapons[3];
    483517        int16_t field_1A0; //10 bucks says this is the current weapon
    484518        int16_t AmmoUsed;                               //Ammo given for the char to use
  • Daodan/MSVC/Oni_Symbols.c

    r567 r568  
    141141DefFunc( ONrPlatform_Initialize                                 , 0x0050f670 );
    142142DefFunc( ONrPlatform_WindowProc                                 , 0x0050f7a0 );
     143DefFunc( iSetCharacterClass                                             , 0x004D99D0 );
     144
    143145
    144146DefFunc( SLrGlobalVariable_Register_Int32               ,       0x0477e30);
  • Daodan/MSVC/Oni_Symbols.h

    r567 r568  
    113113typedef int16_t ( *_TSrContext_New)( void* FontInstance, int size, int hthsik1,int hthsik2,int hthsik3, void* TSrContext);
    114114
     115//yes im cheating so badly.
     116typedef uint16_t ( *_iSetCharacterClass)(sl_callinfo* callinfo, uint32_t numargs, sl_arg args[], int* dontuse1, int* dontuse2, sl_arg* ret);
    115117
    116118#define ExtFunc(name) extern _##name name
     
    151153ExtFunc(ONrGetActiveCharacter);
    152154
     155ExtFunc(iSetCharacterClass);
     156
    153157ExtFunc(COrTextArea_Print);
    154158
Note: See TracChangeset for help on using the changeset viewer.