ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/Daodan/MSVC/Flatline_Server.c
(Generate patch)

Comparing Daodan/MSVC/Flatline_Server.c (file contents):
Revision 567 by gumby, Fri Jun 25 03:52:34 2010 UTC vs.
Revision 568 by gumby, Wed Jun 30 04:25:00 2010 UTC

# Line 52 | Line 52 | server:                ;
52                  new_char.id = NEW_PLAYER;
53                  if(!is_server) {
54                          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 +
58                          PlayerList[playerlist_slot] = Players+player_slot;
59 +                        PlayerList[playerlist_slot]->spawnnumber = player_slot;
60                          PlayerList[playerlist_slot]->Chr = &((Character *)(((GameState * )(ONgGameState))->CharacterStorage))[player_slot];
61 <                        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
63                          sprintf(PlayerList[playerlist_slot]->Chr->Name, "%.31s", name);        
64                          UDPServer_SendToAll( (char*)&new_char, sizeof(new_player) + FLATLINE_HEADER );
65                          
# Line 77 | Line 82 | server:                ;
82  
83   void FLrServer_Initialize(){
84          FLrServer_AddPlayer(inet_addr("127.0.0.1"), "host", 1);
85 + }
86  
87 <
87 > //UDPServer_SendToAll
88 > //Sends a packet to all the clients currently connected.
89 > //Returns the number of players sent to.
90 > int 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;
108   }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)