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

Comparing Daodan/MSVC/Flatline_PacketBuilder.c (file contents):
Revision 584 by gumby, Mon Jan 24 06:45:07 2011 UTC vs.
Revision 585 by gumby, Tue Jan 25 17:18:05 2011 UTC

# Line 31 | Line 31 | void FLsPacketBuild( uint8_t p, PlayerDa
31          if(1)
32          {
33                  memcpy( DataPointer, &PI->InputFromClient, sizeof(PlayerInput));
34 <                PI->InputFromClient = PI->Input;
34 >                PI->Input = PI->InputFromClient;
35  
36                  FLAG_AND_INCREMENT( PFlag_Input );
37          }
# Line 98 | Line 98 | void FLsPacketBuild( uint8_t p, PlayerDa
98  
99          if(APlayer)
100          {
101 <                if( memcmp(&PI->Position, &APlayer->PhyContext->Position, sizeof(Vector3)) )
101 >                if( (APlayer->PhyContext) && memcmp(&PI->Position, &APlayer->PhyContext->Position, sizeof(Vector3)) )
102                  {
103                          Vector3* ptr = (Vector3*)DataPointer;
104                          *ptr = PI->Position = APlayer->PhyContext->Position;
# Line 108 | Line 108 | void FLsPacketBuild( uint8_t p, PlayerDa
108  
109                  if(APlayer->Animation != PI->Animation)
110                  {
111 <                        sprintf_s( DataPointer, 32, "%s", TMrInstance_GetInstanceName( PI->Animation ) );
111 >                        sprintf_s( DataPointer, 32, "%s", TMrInstance_GetInstanceName( APlayer->Animation ) );
112                          PI->Animation = APlayer->Animation;
113                          
114                          FLAG_AND_INCREMENT( PFlag_Animation );
# Line 136 | Line 136 | void FLsPacketBuild( uint8_t p, PlayerDa
136                  }
137          }
138          
139 <        PD->Size = (char)DataPointer - (char)PD;
139 >        PD->Size = (uint32_t)DataPointer - (uint32_t)PD;
140  
141          PI->UpdateFlags = PD->UpdateFlags;      
142          
# Line 167 | Line 167 | void FLsSendPlayerData()
167                          
168                          assert( BuildData[p].Size < 255 );
169                          
170 <                        //If we hit maximum size, send the packet and reset the buffer for a new one
171 <                        if( BuildData[p].Size + PacketSize > max_packet_size )
170 >                        if( BuildData[p].Size > 0 )
171                          {
172 <                                UDPServer_SendToAll(&OutputPacket, PacketSize + FLATLINE_HEADER);
173 <                        
174 <                                memset( OutputPacket.data, 0, PacketSize );
175 <                                OutputPointer = OutputPacket.data;
176 <                                PacketSize = 0;
172 >
173 >                                //If we hit maximum size, send the packet and reset the buffer for a new one
174 >                                if( BuildData[p].Size + PacketSize > max_packet_size )
175 >                                {
176 >                                        UDPServer_SendToAll(&OutputPacket, PacketSize + FLATLINE_HEADER);
177 >
178 >                                        memset( OutputPacket.data, 0, PacketSize );
179 >                                        OutputPointer = OutputPacket.data;
180 >                                        PacketSize = 0;
181 >                                }
182 >
183 >                                //add to the packet
184 >                                memcpy( OutputPointer, &BuildData[p], BuildData[p].Size );
185 >
186 >                                OutputPointer += BuildData[p].Size;
187 >                                PacketSize += BuildData[p].Size;
188                          }
179                        
180                        //add to the packet
181                        memcpy( OutputPointer, &BuildData[p], BuildData[p].Size );
182                        
183                        OutputPointer += BuildData[p].Size;
184                        PacketSize += BuildData[p].Size;
189                  }
190          }
191          //Send data

Diff Legend

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