Changeset 651


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

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

Location:
abuse/trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/configure.ac

    r640 r651  
    2121
    2222AC_ARG_ENABLE(debug,
    23   [  --enable-debug          build debug versions of the game (default no)])
     23  [  --enable-debug          build debug versions of the game (default disabled)])
    2424AC_ARG_ENABLE(release,
    25   [  --enable-release        build final release of the game (default no)])
     25  [  --enable-release        build final release of the game (default disabled)])
    2626AC_ARG_ENABLE(nonfree,
    27   [  --disable-nonfree       disable non-free data (default no)])
     27  [  --disable-nonfree       disable non-free data (default enabled)])
     28AC_ARG_ENABLE(network,
     29  [  --disable-network       disable networking (default enabled)])
    2830
    2931AC_ARG_WITH(assetdir,
     
    8688  ac_cv_have_nonfree="yes"
    8789fi
    88 if test "${enable_nonfree}" = "no"; then
     90if test "x${enable_nonfree}" = xno; then
    8991  ac_cv_have_nonfree="no"
    9092fi
     
    9597fi
    9698AC_SUBST(distdir)
    97 AM_CONDITIONAL(HAVE_NONFREE, test "${ac_cv_have_nonfree}" = "yes")
     99AM_CONDITIONAL(HAVE_NONFREE, test "x${ac_cv_have_nonfree}" = xyes)
     100
     101dnl  Is networking enabled?
     102if test "x${enable_network}" != xno; then
     103  AC_DEFINE(HAVE_NETWORK, 1, Define to 1 to enable networking)
     104fi
     105AM_CONDITIONAL(HAVE_NETWORK, test "x${enable_network}" != xno)
    98106
    99107# Optimizations
  • abuse/trunk/src/Makefile.am

    r605 r651  
    7575abuse_tool_DEPENDENCIES = $(abuse_tool_LDADD)
    7676
    77 INCLUDES = -I$(srcdir) -I $(srcdir)/lisp -I$(srcdir)/imlib \
     77INCLUDES = -I$(srcdir) -I$(srcdir)/lisp -I$(srcdir)/imlib \
    7878           -I$(srcdir)/net $(SDL_CFLAGS)
    7979
    8080CPPFLAGS = @CPPFLAGS@ -DNO_CHECK
     81
  • abuse/trunk/src/clisp.cpp

    r650 r651  
    21882188    case 276 :
    21892189    {
    2190 #if defined __CELLOS_LV2__
    2191       return 0;
    2192 #else
    21932190      if (!main_net_cfg) return 0;
    21942191      return become_server(game_name);
    2195 #endif
    21962192    } break;
    21972193    case 277 :
  • abuse/trunk/src/game.cpp

    r650 r651  
    8484extern uint8_t chatting_enabled;
    8585
    86 // Enabled TCPIP driver
    87 #if !defined __CELLOS_LV2__
     86// Enable TCP/IP driver
     87#if HAVE_NETWORK
    8888#include "tcpip.h"
    8989tcpip_protocol tcpip;
     
    548548    }
    549549
    550 #if !defined __CELLOS_LV2__
    551550    base->current_tick=(current_level->tick_counter()&0xff);
    552 #endif
    553551
    554552    current_level->level_loaded_notify();
     
    13891387  calc_light_table(pal);
    13901388
    1391 #if !defined __CELLOS_LV2__
    13921389  if(current_level == NULL && net_start())  // if we joined a net game get level from server
    13931390  {
     
    13991396//    load_level(NET_STARTFILE);
    14001397  }
    1401 #endif
    14021398
    14031399  set_mode(19, argc, argv);
     
    14661462  gamma_correct(pal);
    14671463
    1468 #if defined __CELLOS_LV2__
    1469   if(!start_edit)
    1470     do_title();
    1471 #else
    14721464  if(main_net_cfg == NULL || (main_net_cfg->state != net_configuration::SERVER &&
    14731465                 main_net_cfg->state != net_configuration::CLIENT))
     
    14801472    start_running = 1;
    14811473  }
    1482 #endif
    14831474
    14841475
     
    16621653        if(ev.type != EV_KEY || !key_down(ev.key) || ev.window || (dev & EDIT_MODE))
    16631654        {
    1664 #if !defined __CELLOS_LV2__
    16651655            if(ev.type == EV_KEY)
    16661656            {
     
    17001690                }
    17011691            }
    1702 #endif
    17031692
    17041693            if((dev & EDIT_MODE) || start_edit || ev.type == EV_MESSAGE)
     
    19151904void net_send(int force = 0)
    19161905{
    1917 #if !defined __CELLOS_LV2__
    19181906  if((!(dev & EDIT_MODE)) || force)
    19191907  {
     
    19501938    }
    19511939  }
    1952 #endif
    19531940}
    19541941
    19551942void net_receive()
    19561943{
    1957 #if !defined __CELLOS_LV2__
    19581944  if(!(dev & EDIT_MODE) && current_level)
    19591945  {
     
    19761962    process_packet_commands(buf, size);
    19771963  }
    1978 #endif
    19791964}
    19801965
     
    23442329void game_net_init(int argc, char **argv)
    23452330{
    2346 #if !defined __CELLOS_LV2__
    23472331  int nonet=!net_init(argc, argv);
    23482332  if(nonet)
     
    23692353    }
    23702354  }
    2371 #endif
    23722355}
    23732356
     
    24662449        g->get_input(); // prime the net
    24672450
    2468 #if !defined __CELLOS_LV2__
    24692451        for (int i = 1; i + 1 < argc; i++)
    24702452        {
     
    24902472            g->update_screen(); // redraw the screen with any changes
    24912473        }
    2492 #endif
    24932474
    24942475        while (!g->done())
     
    25252506                demo_man.do_inputs();
    25262507
    2527 #if !defined __CELLOS_LV2__
    25282508            service_net_request();
    2529 #endif
    25302509
    25312510            // process all the objects in the world
    25322511            g->step();
    2533 #if !defined __CELLOS_LV2__
    25342512            server_check();
    2535 #endif
    25362513            g->calc_speed();
    25372514
     
    25412518        }
    25422519
    2543 #if !defined __CELLOS_LV2__
    25442520        net_uninit();
    25452521
     
    25472523            net_crcs->clean_up();
    25482524        delete net_crcs; net_crcs = NULL;
    2549 #endif
    25502525
    25512526        delete chat;
     
    25862561        Lisp::Uninit();
    25872562
    2588 #if !defined __CELLOS_LV2__
    25892563        base->packet.packet_reset();
    2590 #endif
    25912564    }
    25922565    while (main_net_cfg && main_net_cfg->restart_state());
  • 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
  • abuse/trunk/src/loader2.cpp

    r635 r651  
    315315#endif
    316316
    317 #if defined __CELLOS_LV2__
    318   if (1)
    319 #else
    320317  // don't let them specify a startup file we are connect elsewhere
    321318  if (!net_start())
    322 #endif
    323319  {
    324320    for (int i=1; i<argc; i++)
     
    336332    }
    337333  }
    338 #if !defined __CELLOS_LV2__
    339334  else if (!get_remote_lsf(net_server,lsf))
    340335  {
     
    342337    exit(0);
    343338  }
    344 #endif
    345339  char prog[100];
    346340  char const *cs;
  • abuse/trunk/src/menu.cpp

    r650 r651  
    3838#include "netcfg.h"
    3939
    40 #if !defined __CELLOS_LV2__
    41 #   include "net/sock.h"
     40#include "net/sock.h"
     41
    4242extern net_protocol *prot;
    43 #else
    44 static int const prot = 0;
    45 #endif
    4643
    4744static VolumeWindow *volume_window;
  • abuse/trunk/src/net/Makefile.am

    r524 r651  
    1 ## Process this file with automake to produce Makefile.in
     1
    22noinst_LIBRARIES = libnet.a
    33
     
    1414
    1515CPPFLAGS = @CPPFLAGS@ -DNO_CHECK
     16
  • abuse/trunk/src/net/engine.cpp

    r643 r651  
    1313#endif
    1414
     15#if HAVE_NETWORK
    1516#include "common.h"
    1617
     
    12501251}
    12511252
    1252 
    1253 
    1254 
    1255 
    1256 
     1253#endif // HAVE_NETWORK
     1254
  • abuse/trunk/src/net/fileman.cpp

    r555 r651  
    1313#endif
    1414
     15#if HAVE_NETWORK
     16
    1517#include <stdio.h>
    1618#include <stdlib.h>
     
    518520  else return 0;
    519521}
     522
     523#endif // HAVE_NETWORK
     524
  • abuse/trunk/src/net/gclient.cpp

    r555 r651  
    2020#include <sys/types.h>
    2121#include <string.h>
    22 #include <signal.h>
    2322
    2423#include "common.h"
  • abuse/trunk/src/net/gserver.cpp

    r646 r651  
    2020#include <sys/types.h>
    2121#include <string.h>
    22 #include <signal.h>
    2322
    2423#include "common.h"
  • abuse/trunk/src/net/netdrv.cpp

    r555 r651  
    1212#   include "config.h"
    1313#endif
     14
     15#if HAVE_NETWORK
    1416
    1517#include <stdio.h>
     
    599601  return 0;
    600602}
     603
     604#endif // HAVE_NETWORK
     605
  • abuse/trunk/src/net/netfile.cpp

    r555 r651  
    1313#endif
    1414
     15#if HAVE_NETWORK
     16
    1517#include "common.h"
    1618
     
    1820#include "../inc/netface.h"
    1921#include "engine.h"
    20 
    2122
    2223nfs_client *first_nfs_client=NULL;
     
    473474}
    474475
    475 
     476#endif // HAVE_NETWORK
     477
  • abuse/trunk/src/net/sock.cpp

    r555 r651  
    2222net_protocol *net_protocol::first=0;
    2323
     24#if HAVE_NETWORK
    2425// connect to an explictedly named address
    2526// first try to get the address and then try to connect
    2627// return NULL if either fail.  This method does not need to be implemented
    2728// in sub-classes
    28 
    2929net_socket *net_protocol::connect_to_server(char const *&server_name, int port, int force_port, net_socket::socket_type sock_type)
    3030{
     
    3535  return s;
    3636}
     37#endif
    3738
  • abuse/trunk/src/net/tcpip.cpp

    r555 r651  
    1212#   include "config.h"
    1313#endif
     14
     15#if HAVE_NETWORK
    1416
    1517#ifdef _AIX
     
    683685//}}}
    684686
     687#endif
     688
  • abuse/trunk/src/net/undrv.cpp

    r643 r651  
    1212#   include "config.h"
    1313#endif
     14
     15#if HAVE_NETWORK
    1416
    1517#include <stdio.h>
     
    200202    fman->process_net();
    201203  }
    202 
    203 
    204 }
    205 
     204}
     205
     206#endif // HAVE_NETWORK
     207
  • abuse/trunk/src/netcfg.cpp

    r650 r651  
    2525#include "dev.h"
    2626
    27 #if !defined __CELLOS_LV2__
    28 #   include "net/sock.h"
    29 #endif
     27#include "net/sock.h"
    3028
    3129extern char *get_login();
     
    3331extern char lsf[256];
    3432
    35 #if !defined __CELLOS_LV2__
    3633extern net_protocol *prot;
    37 #endif
    3834
    3935net_configuration::net_configuration()
    4036{
    41 #if !defined __CELLOS_LV2__
    4237  strcpy(name,get_login());
    4338
    4439  strcpy(server_name,"My Netgame");
    45 
    4640
    4741  min_players=2;
     
    5145  server_port=20202;
    5246  state=SINGLE_PLAYER;
    53 #endif
    5447}
    5548
     
    454447{
    455448  int ret=0;
    456 #if !defined __CELLOS_LV2__
    457449  main_screen->clear();
    458450
     
    599591    }
    600592  }
    601 #endif
    602593
    603594  return ret;
  • abuse/trunk/src/nfclient.cpp

    r555 r651  
    3030#include "cache.h"
    3131
    32 #include "gserver.h"
    33 
    34 #if !defined __CELLOS_LV2__
     32#include "net/gserver.h"
    3533
    3634void remove_client(int client_number) { ; }
     
    115113  }
    116114
    117 
     115#if HAVE_NETWORK
    118116  if (local_only)
    119117  {
     118#endif
    120119    local=new jFILE(filename,mode);
    121120    if (local->open_failure()) { delete local; local=NULL; }
     121#if HAVE_NETWORK
    122122  }
    123123  else
    124124  {
    125 
    126 
    127125    char nm[256];
    128126    strcpy(nm,filename);
     
    135133    }
    136134  }
     135#endif
    137136}
    138137
     
    149148  if (local)
    150149    return local->read(buf,count);
     150#if HAVE_NETWORK
    151151  else if (nfs_fd>=0)
    152152  {
     
    158158    return a;
    159159  }
     160#endif
    160161  else return 0;
    161162}
     
    165166  if (local)
    166167    return local->write(buf,count);
     168#if HAVE_NETWORK
    167169  else
    168170  {
     
    170172    exit(0);
    171173  }
     174#endif
    172175  return 0;
    173176}
     
    178181  if (local)
    179182    return local->seek(off,whence);
     183#if HAVE_NETWORK
    180184  else if (nfs_fd>=0)
    181185  {
     
    185189      return NF_seek(nfs_fd,off);
    186190  }
     191#endif
    187192  return 0;
    188193}
     
    191196{
    192197  if (local)          return local->tell();
     198#if HAVE_NETWORK
    193199  else if (nfs_fd>=0) return NF_tell(nfs_fd);
     200#endif
    194201  else                return 0;
    195202}
     
    199206{
    200207  if (local)          return local->file_size();
     208#if HAVE_NETWORK
    201209  else if (nfs_fd>=0) return NF_filelength(nfs_fd);
     210#endif
    202211  else                return 0;
    203212}
     
    207216  flush_writes();
    208217  if (local)          delete local;
     218#if HAVE_NETWORK
    209219  else if (nfs_fd>=0) NF_close(nfs_fd);
     220#endif
    210221}
    211222
    212223int set_file_server(net_address *addr)
    213224{
     225#if HAVE_NETWORK
    214226  if (NF_set_file_server(addr))
    215227  {
     
    229241    return 1;
    230242  }
     243#endif
    231244  return 0;
    232245}
     
    247260}
    248261
    249 #endif
    250 
  • abuse/trunk/src/nfserver.h

    r555 r651  
    1212#define __NFSERVER_HPP_
    1313
    14 #if !defined __CELLOS_LV2__
    15 
    1614#include "specs.h"
    1715#include "netface.h"
    18 #include "sock.h"
     16#include "net/sock.h"
    1917
    2018int net_init(int argc, char **argv);
     
    5755
    5856#endif
    59 #endif
     57
  • abuse/trunk/src/view.cpp

    r643 r651  
    394394    }
    395395
    396 #if !defined __CELLOS_LV2__
    397396    if( view_changed() )
    398397    {
     
    443442    base->packet.write_uint16((uint16_t)((int16_t)sug_px));
    444443    base->packet.write_uint16((uint16_t)((int16_t)sug_py));
    445 #endif
    446444}
    447445
     
    494492int view::process_input(char cmd, uint8_t *&pk)   // return 0 if something went wrong
    495493{
    496 #if !defined __CELLOS_LV2__
    497494  switch (cmd)
    498495  {
     
    566563    case SCMD_EXT_KEYRELEASE : set_key_down(*(pk++)+256,0); break;
    567564  }
    568 #endif
    569565  return 1;
    570566}
     
    572568int view::local_player()
    573569{
    574 #if defined __CELLOS_LV2__
    575   return 1;
    576 #else
    577570  return player_number==client_number();
    578 #endif
    579571}
    580572
     
    11781170void process_packet_commands(uint8_t *pk, int size)
    11791171{
    1180 #if !defined __CELLOS_LV2__
    11811172  int32_t sync_uint16=-1;
    11821173
     
    12781269    }
    12791270  } while (cmd!=SCMD_END_OF_PACKET);
    1280 #endif
    12811271}
    12821272
Note: See TracChangeset for help on using the changeset viewer.