Ignore:
Timestamp:
Nov 10, 2005, 9:41:13 PM (17 years ago)
Author:
Sam Hocevar
Message:
  • absolute shitloads of 64 bit fixes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/include/netface.hpp

    r2 r17  
    9696struct net_packet
    9797{
    98   unsigned char data[PACKET_MAX_SIZE];
     98  uint8_t data[PACKET_MAX_SIZE];
    9999  int packet_prefix_size()                 { return 5; }    // 2 byte size, 2 byte check sum, 1 byte packet order
    100   unsigned short packet_size()             { unsigned short size=(*(unsigned short *)data); return lstl(size); }
    101   unsigned char tick_received()            { return data[4]; } 
    102   void set_tick_received(unsigned char x)  { data[4]=x; }
    103   unsigned char *packet_data()             { return data+packet_prefix_size(); }
    104   unsigned short get_checksum()            { unsigned short cs=*((unsigned short *)data+1); return lstl(cs); }
    105   unsigned short calc_checksum()
     100  uint16_t packet_size()             { uint16_t size=(*(uint16_t *)data); return lstl(size); }
     101  uint8_t tick_received()            { return data[4]; } 
     102  void set_tick_received(uint8_t x)  { data[4]=x; }
     103  uint8_t *packet_data()             { return data+packet_prefix_size(); }
     104  uint16_t get_checksum()            { uint16_t cs=*((uint16_t *)data+1); return lstl(cs); }
     105  uint16_t calc_checksum()
    106106  {
    107     *((unsigned short *)data+1)=0;
     107    *((uint16_t *)data+1)=0;
    108108    int i,size=packet_prefix_size()+packet_size();
    109     unsigned char c1=0,c2=0,*p=data;
     109    uint8_t c1=0,c2=0,*p=data;
    110110    for (i=0;i<size;i++,p++)
    111111    {
     
    113113      c2+=c1;
    114114    }
    115     unsigned short cs=( (((unsigned short)c1)<<8) | c2);
    116     *((unsigned short *)data+1)=lstl(cs);
     115    uint16_t cs=( (((uint16_t)c1)<<8) | c2);
     116    *((uint16_t *)data+1)=lstl(cs);
    117117    return cs;
    118118  }
     
    129129    }
    130130  }
    131   void write_byte(unsigned char x) { add_to_packet(&x,1); }
    132   void write_short(unsigned short x) { x=lstl(x); add_to_packet(&x,2); }
    133   void write_long(unsigned long x) { x=lltl(x); add_to_packet(&x,4); }
     131  void write_uint8(uint8_t x) { add_to_packet(&x,1); }
     132  void write_uint16(uint16_t x) { x=lstl(x); add_to_packet(&x,2); }
     133  void write_uint32(uint32_t x) { x=lltl(x); add_to_packet(&x,4); }
    134134
    135   void set_packet_size(unsigned short x) { *((unsigned short *)data)=lstl(x); }
     135  void set_packet_size(uint16_t x) { *((uint16_t *)data)=lstl(x); }
    136136
    137137
     
    143143             last_packet;                   // last tick data (in case a client misses input, we can resend)
    144144
    145   short mem_lock;
    146   short calc_crcs;
    147   short get_lsf;
    148   short wait_reload;
    149   short need_reload;
    150   short input_state;            // COLLECTING or PROCESSING
    151   short current_tick;           // set by engine, used by driver to confirm packet is not left over
     145  int16_t mem_lock;
     146  int16_t calc_crcs;
     147  int16_t get_lsf;
     148  int16_t wait_reload;
     149  int16_t need_reload;
     150  int16_t input_state;          // COLLECTING or PROCESSING
     151  int16_t current_tick;         // set by engine, used by driver to confirm packet is not left over
    152152 
    153153  join_struct *join_list;
Note: See TracChangeset for help on using the changeset viewer.