Ignore:
Timestamp:
May 14, 2011, 3:06:27 AM (9 years ago)
Author:
Sam Hocevar
Message:

build: add a --disable-network compilation flag and get rid of most of
the CELLOS_LV2 ifdefs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/innet.cpp

    r645 r651  
    2323#include "dev.h"
    2424#include "timing.h"
    25 #include "fileman.h"
    2625#include "netface.h"
    2726
    28 #include "gserver.h"
    29 #include "gclient.h"
     27#if HAVE_NETWORK
     28#   include "fileman.h"
     29#endif
     30#include "net/sock.h"
     31#include "net/ghandler.h"
     32#include "net/gserver.h"
     33#include "net/gclient.h"
    3034#include "dprint.h"
    3135#include "netcfg.h"
     
    4549base_memory_struct *base;   // points to shm_addr
    4650base_memory_struct local_base;
    47 net_address *net_server=NULL;
    48 net_protocol *prot=NULL;
    49 net_socket *comm_sock=NULL,*game_sock=NULL;
     51net_address *net_server = NULL;
     52net_protocol *prot = NULL;
     53net_socket *comm_sock = NULL, *game_sock = NULL;
     54game_handler *game_face = NULL;
    5055extern char lsf[256];
    51 game_handler *game_face=NULL;
    5256int local_client_number=0;        // 0 is the server
    5357join_struct *join_array=NULL;      // points to an array of possible joining clients
     
    5862int net_init(int argc, char **argv)
    5963{
    60 #if defined __CELLOS_LV2__
    61     return 0;
    62 #else
    6364    int i,x,db_level=0;
    6465    base=&local_base;
     
    150151    prot=usable;
    151152    prot->set_debug_printing((net_protocol::debug_type)db_level);
     153
    152154    if (main_net_cfg->state==net_configuration::SERVER)
    153155        set_login(main_net_cfg->name);
     
    167169    }
    168170
    169     fman=new file_manager(argc,argv,prot);                                       // manages remote file access
    170     game_face=new game_handler;
     171#if HAVE_NETWORK
     172    fman = new file_manager(argc,argv,prot); // manages remote file access
     173#endif
     174    game_face = new game_handler;
    171175    join_array=(join_struct *)malloc(sizeof(join_struct)*MAX_JOINERS);
    172176    base->join_list=NULL;
     
    181185
    182186    return 1;
    183 #endif
    184 }
    185 
    186 
    187 
     187}
    188188
    189189int net_start()  // is the game starting up off the net? (i.e. -net hostname)
    190 {   return (main_net_cfg && main_net_cfg->state==net_configuration::CLIENT);  }
    191 
    192 
     190{
     191    return main_net_cfg && main_net_cfg->state == net_configuration::CLIENT;
     192}
    193193
    194194int kill_net()
    195195{
    196 #if defined __CELLOS_LV2__
    197   return 0;
    198 #else
    199196  if (game_face) delete game_face;  game_face=NULL;
    200197  if (join_array) free(join_array);  join_array=NULL;
    201198  if (game_sock) { delete game_sock; game_sock=NULL; }
    202199  if (comm_sock) { delete comm_sock; comm_sock=NULL; }
     200#if HAVE_NETWORK
    203201  delete fman;  fman=NULL;
     202#endif
    204203  if (net_server) { delete net_server; net_server=NULL; }
    205204  if (prot)
    206205  {
    207 
    208206    prot->cleanup();
    209207    prot=NULL;
    210208    return 1;
    211   } else return 0;
    212 #endif
     209  }
     210  return 0;
    213211}
    214212
     
    219217
    220218
     219#if HAVE_NETWORK
    221220int NF_set_file_server(net_address *addr)
    222221{
    223 #if defined __CELLOS_LV2__
    224   return 0;
    225 #else
    226222  if (prot)
    227223  {
     
    237233    return cmd;
    238234  } else return 0;
    239 #endif
    240235}
    241236
    242237int NF_set_file_server(char const *name)
    243238{
    244 #if !defined __CELLOS_LV2__
    245239  if (prot)
    246240  {
     
    253247    } else return 0;
    254248  }
    255 #endif
    256249  return 0;
    257250}
     
    260253int NF_open_file(char const *filename, char const *mode)
    261254{
    262 #if !defined __CELLOS_LV2__
    263255    if (prot)
    264256        return fman->rf_open_file(filename,mode);
     257    return -2;
     258}
     259
     260
     261long NF_close(int fd)
     262{
     263  if (prot)
     264    return fman->rf_close(fd);
     265  return 0;
     266}
     267
     268long NF_read(int fd, void *buf, long size)
     269{
     270  if (prot)
     271    return fman->rf_read(fd,buf,size);
     272  return 0;
     273}
     274
     275long NF_filelength(int fd)
     276{
     277  if (prot)
     278    return fman->rf_file_size(fd);
     279  return 0;
     280}
     281
     282long NF_seek(int fd, long offset)
     283{
     284  if (prot)
     285    return fman->rf_seek(fd,offset);
     286  return 0;
     287}
     288
     289long NF_tell(int fd)
     290{
     291  if (prot)
     292    return fman->rf_tell(fd);
     293  return 0;
     294}
    265295#endif
    266     return -2;
    267 }
    268 
    269 
    270 long NF_close(int fd)
    271 {
    272 #if !defined __CELLOS_LV2__
    273   if (prot)
    274     return fman->rf_close(fd);
    275 #endif
    276   return 0;
    277 }
    278 
    279 long NF_read(int fd, void *buf, long size)
    280 {
    281 #if !defined __CELLOS_LV2__
    282   if (prot)
    283     return fman->rf_read(fd,buf,size);
    284 #endif
    285   return 0;
    286 }
    287 
    288 long NF_filelength(int fd)
    289 {
    290 #if !defined __CELLOS_LV2__
    291   if (prot)
    292     return fman->rf_file_size(fd);
    293 #endif
    294   return 0;
    295 }
    296 
    297 long NF_seek(int fd, long offset)
    298 {
    299 #if !defined __CELLOS_LV2__
    300   if (prot)
    301     return fman->rf_seek(fd,offset);
    302 #endif
    303   return 0;
    304 }
    305 
    306 long NF_tell(int fd)
    307 {
    308 #if !defined __CELLOS_LV2__
    309   if (prot)
    310     return fman->rf_tell(fd);
    311 #endif
    312   return 0;
    313 }
    314296
    315297
    316298void service_net_request()
    317299{
    318 #if !defined __CELLOS_LV2__
     300#if HAVE_NETWORK
    319301  if (prot)
    320302  {
     
    379361    }
    380362  }
    381 #endif
     363#endif // HAVE_NETWORK
    382364}
    383365
     
    385367int get_remote_lsf(net_address *addr, char *filename)  // filename should be 256 bytes
    386368{
    387 #if !defined __CELLOS_LV2__
    388369  if (prot)
    389370  {
     
    406387
    407388  }
    408 #endif
    409389  return 0;
    410390}
     
    414394int request_server_entry()
    415395{
    416 #if !defined __CELLOS_LV2__
    417396  if (prot && main_net_cfg)
    418397  {
     
    487466    return cnum;
    488467  }
    489 #endif
    490468  return 0;
    491469}
     
    493471int reload_start()
    494472{
    495 #if !defined __CELLOS_LV2__
    496473  if (prot)
    497474    return game_face->start_reload();
    498 #endif
    499475  return 0;
    500476}
     
    502478int reload_end()
    503479{
    504 #if !defined __CELLOS_LV2__
    505480  if (prot)
    506481    return game_face->end_reload();
    507 #endif
    508482  return 0;
    509483}
     
    512486void net_reload()
    513487{
    514 #if !defined __CELLOS_LV2__
    515488  if (prot)
    516489  {
     
    632605    }
    633606  }
    634 #endif
    635607}
    636608
     
    641613void send_local_request()
    642614{
    643 
    644615  if (prot)
    645616  {
     
    745716int become_server(char *name)
    746717{
    747 #if !defined __CELLOS_LV2__
    748718  if (prot && main_net_cfg)
    749719  {
     
    765735    return 1;
    766736  }
    767 #endif
    768737  return 0;
    769738}
     
    771740void read_new_views() { ; }
    772741
    773 
    774742void wait_min_players()
    775743{
    776   if (game_face) game_face->game_start_wait();
    777 }
    778 
     744    if (game_face)
     745        game_face->game_start_wait();
     746}
     747
Note: See TracChangeset for help on using the changeset viewer.