diff --git a/configure.ac b/configure.ac index 6635eac..3489753 100644 --- a/configure.ac +++ b/configure.ac @@ -13,9 +13,16 @@ BUILDSYS_INIT AC_PROG_CC AC_PROG_CPP +AC_PROG_OBJCXX(clang++ g++) +AC_PROG_OBJCXXCPP -AC_PROG_CXX -AC_PROG_CXXCPP +AC_CHECK_TOOL(OBJFW_CONFIG, objfw-config) +AS_IF([test x"$OBJFW_CONFIG" = x""], [ + AC_MSG_ERROR(You need ObjFW and objfw-config installed!) +]) +OBJCXXFLAGS="$OBJCXXFLAGS $($OBJFW_CONFIG --cppflags --objcflags)" +LDFLAGS="$($OBJFW_CONFIG --ldflags --rpath)" +LIBS="$($OBJFW_CONFIG --libs) $LIBS" AC_PATH_TOOL(AR, ar) AC_PATH_TOOL(RANLIB, ranlib) diff --git a/src/Makefile b/src/Makefile index 5602351..71d6f67 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,37 +1,37 @@ PROG = client -SRCS = client.cxx \ - clientextras.cxx \ - clientgame.cxx \ - clients2c.cxx \ - command.cxx \ - console.cxx \ - editing.cxx \ - entities.cxx \ - main.cxx \ - menus.cxx \ - monster.cxx \ - physics.cxx \ - rendercubes.cxx \ - renderextras.cxx \ - rendergl.cxx \ - rendermd2.cxx \ - renderparticles.cxx \ - rendertext.cxx \ - rndmap.cxx \ - savegamedemo.cxx \ - server.cxx \ - serverbrowser.cxx \ - serverms.cxx \ - serverutil.cxx \ - sound.cxx \ - tools.cxx \ - weapon.cxx \ - world.cxx \ - worldio.cxx \ - worldlight.cxx \ - worldocull.cxx \ - worldrender.cxx +SRCS = client.mm \ + clientextras.mm \ + clientgame.mm \ + clients2c.mm \ + command.mm \ + console.mm \ + editing.mm \ + entities.mm \ + main.mm \ + menus.mm \ + monster.mm \ + physics.mm \ + rendercubes.mm \ + renderextras.mm \ + rendergl.mm \ + rendermd2.mm \ + renderparticles.mm \ + rendertext.mm \ + rndmap.mm \ + savegamedemo.mm \ + server.mm \ + serverbrowser.mm \ + serverms.mm \ + serverutil.mm \ + sound.mm \ + tools.mm \ + weapon.mm \ + world.mm \ + worldio.mm \ + worldlight.mm \ + worldocull.mm \ + worldrender.mm include ../buildsys.mk include ../extra.mk @@ -47,5 +47,6 @@ LIBS += -L../enet -lenet \ ${GL_LIBS} \ ${GLU_LIBS} \ ${X11_LIBS} \ - ${ZLIB_LIBS} -LD = ${CXX} + ${ZLIB_LIBS} \ + -lm +LD = ${OBJCXX} diff --git a/src/client.cxx b/src/client.mm similarity index 100% rename from src/client.cxx rename to src/client.mm diff --git a/src/clientextras.cxx b/src/clientextras.mm similarity index 100% rename from src/clientextras.cxx rename to src/clientextras.mm diff --git a/src/clientgame.cxx b/src/clientgame.mm similarity index 100% rename from src/clientgame.cxx rename to src/clientgame.mm diff --git a/src/clients2c.cxx b/src/clients2c.mm similarity index 100% rename from src/clients2c.cxx rename to src/clients2c.mm diff --git a/src/command.cxx b/src/command.mm similarity index 88% rename from src/command.cxx rename to src/command.mm index 3da86d5..fe486e6 100644 --- a/src/command.cxx +++ b/src/command.mm @@ -155,15 +155,15 @@ parseword(char *&p) // parse single argument, including expressions char * lookup(char *n) // find value of ident referenced with $ in exp { - ident *id = idents->access(n + 1); - if (id) - switch (id->type) { + ident *ID = idents->access(n + 1); + if (ID) + switch (ID->type) { case ID_VAR: string t; - itoa(t, *(id->storage)); + itoa(t, *(ID->storage)); return exchangestr(n, t); case ID_ALIAS: - return exchangestr(n, id->action); + return exchangestr(n, ID->action); }; conoutf("unknown alias lookup: %s", n + 1); return n; @@ -202,98 +202,98 @@ execute(char *p, bool isdown) // all evaluation happens here, recursively if (!*c) continue; // empty statement - ident *id = idents->access(c); - if (!id) { + ident *ID = idents->access(c); + if (!ID) { val = ATOI(c); if (!val && *c != '0') conoutf("unknown command: %s", c); } else - switch (id->type) { + switch (ID->type) { case ID_COMMAND: // game defined commands - switch (id->narg) // use very ad-hoc function + switch (ID->narg) // use very ad-hoc function // signature, and just call it { case ARG_1INT: if (isdown) - ((void(__cdecl *)(int))id->fun)( + ((void(__cdecl *)(int))ID->fun)( ATOI(w[1])); break; case ARG_2INT: if (isdown) ((void(__cdecl *)( - int, int))id->fun)( + int, int))ID->fun)( ATOI(w[1]), ATOI(w[2])); break; case ARG_3INT: if (isdown) ((void(__cdecl *)(int, int, - int))id->fun)(ATOI(w[1]), + int))ID->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3])); break; case ARG_4INT: if (isdown) ((void(__cdecl *)(int, int, int, - int))id->fun)(ATOI(w[1]), + int))ID->fun)(ATOI(w[1]), ATOI(w[2]), ATOI(w[3]), ATOI(w[4])); break; case ARG_NONE: if (isdown) - ((void(__cdecl *)())id->fun)(); + ((void(__cdecl *)())ID->fun)(); break; case ARG_1STR: if (isdown) ((void(__cdecl *)( - char *))id->fun)(w[1]); + char *))ID->fun)(w[1]); break; case ARG_2STR: if (isdown) ((void(__cdecl *)( - char *, char *))id->fun)( + char *, char *))ID->fun)( w[1], w[2]); break; case ARG_3STR: if (isdown) ((void(__cdecl *)(char *, - char *, char *))id->fun)( + char *, char *))ID->fun)( w[1], w[2], w[3]); break; case ARG_5STR: if (isdown) ((void(__cdecl *)(char *, char *, char *, char *, - char *))id->fun)(w[1], w[2], + char *))ID->fun)(w[1], w[2], w[3], w[4], w[5]); break; case ARG_DOWN: - ((void(__cdecl *)(bool))id->fun)( + ((void(__cdecl *)(bool))ID->fun)( isdown); break; case ARG_DWN1: ((void(__cdecl *)(bool, - char *))id->fun)(isdown, w[1]); + char *))ID->fun)(isdown, w[1]); break; case ARG_1EXP: if (isdown) val = ((int(__cdecl *)( - int))id->fun)( + int))ID->fun)( execute(w[1])); break; case ARG_2EXP: if (isdown) val = ((int(__cdecl *)(int, - int))id->fun)(execute(w[1]), + int))ID->fun)(execute(w[1]), execute(w[2])); break; case ARG_1EST: if (isdown) val = ((int(__cdecl *)( - char *))id->fun)(w[1]); + char *))ID->fun)(w[1]); break; case ARG_2EST: if (isdown) val = ((int(__cdecl *)( - char *, char *))id->fun)( + char *, char *))ID->fun)( w[1], w[2]); break; case ARG_VARI: @@ -312,7 +312,7 @@ execute(char *p, bool isdown) // all evaluation happens here, recursively strcat_s(r, " "); }; ((void(__cdecl *)( - char *))id->fun)(r); + char *))ID->fun)(r); break; } }; @@ -322,36 +322,36 @@ execute(char *p, bool isdown) // all evaluation happens here, recursively if (isdown) { if (!w[1][0]) conoutf("%s = %d", c, - *id->storage); // var with + *ID->storage); // var with // no value // just // prints its // current // value else { - if (id->min > id->max) { + if (ID->min > ID->max) { conoutf("variable is " "read-only"); } else { int i1 = ATOI(w[1]); - if (i1 < id->min || - i1 > id->max) { + if (i1 < ID->min || + i1 > ID->max) { i1 = - i1 < id->min - ? id->min - : id->max; // clamp to valid range + i1 < ID->min + ? ID->min + : ID->max; // clamp to valid range conoutf( "valid " "range for " "%s is " "%d..%d", - c, id->min, - id->max); + c, ID->min, + ID->max); } - *id->storage = i1; + *ID->storage = i1; }; - if (id->fun) - ((void(__cdecl *)())id + if (ID->fun) + ((void(__cdecl *)())ID ->fun)(); // call // trigger // function @@ -371,7 +371,7 @@ execute(char *p, bool isdown) // all evaluation happens here, recursively alias(t, w[i]); }; char *action = newstring( - id->action); // create new string here + ID->action); // create new string here // because alias could rebind // itself val = execute(action, isdown); @@ -454,16 +454,16 @@ writecfg() writeclientinfo(f); fprintf(f, "\n"); enumerate( - idents, ident *, id, if (id->type == ID_VAR && id->persist) { - fprintf(f, "%s %d\n", id->name, *id->storage); + idents, ident *, ID, if (ID->type == ID_VAR && ID->persist) { + fprintf(f, "%s %d\n", ID->name, *ID->storage); };); fprintf(f, "\n"); writebinds(f); fprintf(f, "\n"); enumerate( - idents, ident *, id, - if (id->type == ID_ALIAS && !strstr(id->name, "nextmap_")) { - fprintf(f, "alias \"%s\" [%s]\n", id->name, id->action); + idents, ident *, ID, + if (ID->type == ID_ALIAS && !strstr(ID->name, "nextmap_")) { + fprintf(f, "alias \"%s\" [%s]\n", ID->name, ID->action); };); fclose(f); }; diff --git a/src/console.cxx b/src/console.mm similarity index 100% rename from src/console.cxx rename to src/console.mm diff --git a/src/editing.cxx b/src/editing.mm similarity index 100% rename from src/editing.cxx rename to src/editing.mm diff --git a/src/entities.cxx b/src/entities.mm similarity index 100% rename from src/entities.cxx rename to src/entities.mm diff --git a/src/main.cxx b/src/main.mm similarity index 100% rename from src/main.cxx rename to src/main.mm diff --git a/src/menus.cxx b/src/menus.mm similarity index 100% rename from src/menus.cxx rename to src/menus.mm diff --git a/src/monster.cxx b/src/monster.mm similarity index 100% rename from src/monster.cxx rename to src/monster.mm diff --git a/src/physics.cxx b/src/physics.mm similarity index 100% rename from src/physics.cxx rename to src/physics.mm diff --git a/src/rendercubes.cxx b/src/rendercubes.mm similarity index 100% rename from src/rendercubes.cxx rename to src/rendercubes.mm diff --git a/src/renderextras.cxx b/src/renderextras.mm similarity index 100% rename from src/renderextras.cxx rename to src/renderextras.mm diff --git a/src/rendergl.cxx b/src/rendergl.mm similarity index 100% rename from src/rendergl.cxx rename to src/rendergl.mm diff --git a/src/rendermd2.cxx b/src/rendermd2.mm similarity index 100% rename from src/rendermd2.cxx rename to src/rendermd2.mm diff --git a/src/renderparticles.cxx b/src/renderparticles.mm similarity index 100% rename from src/renderparticles.cxx rename to src/renderparticles.mm diff --git a/src/rendertext.cxx b/src/rendertext.mm similarity index 100% rename from src/rendertext.cxx rename to src/rendertext.mm diff --git a/src/rndmap.cxx b/src/rndmap.mm similarity index 100% rename from src/rndmap.cxx rename to src/rndmap.mm diff --git a/src/savegamedemo.cxx b/src/savegamedemo.mm similarity index 100% rename from src/savegamedemo.cxx rename to src/savegamedemo.mm diff --git a/src/server.cxx b/src/server.mm similarity index 100% rename from src/server.cxx rename to src/server.mm diff --git a/src/serverbrowser.cxx b/src/serverbrowser.mm similarity index 100% rename from src/serverbrowser.cxx rename to src/serverbrowser.mm diff --git a/src/serverms.cxx b/src/serverms.mm similarity index 100% rename from src/serverms.cxx rename to src/serverms.mm diff --git a/src/serverutil.cxx b/src/serverutil.mm similarity index 100% rename from src/serverutil.cxx rename to src/serverutil.mm diff --git a/src/sound.cxx b/src/sound.mm similarity index 100% rename from src/sound.cxx rename to src/sound.mm diff --git a/src/tools.cxx b/src/tools.mm similarity index 100% rename from src/tools.cxx rename to src/tools.mm diff --git a/src/weapon.cxx b/src/weapon.mm similarity index 100% rename from src/weapon.cxx rename to src/weapon.mm diff --git a/src/world.cxx b/src/world.mm similarity index 100% rename from src/world.cxx rename to src/world.mm diff --git a/src/worldio.cxx b/src/worldio.mm similarity index 100% rename from src/worldio.cxx rename to src/worldio.mm diff --git a/src/worldlight.cxx b/src/worldlight.mm similarity index 100% rename from src/worldlight.cxx rename to src/worldlight.mm diff --git a/src/worldocull.cxx b/src/worldocull.mm similarity index 100% rename from src/worldocull.cxx rename to src/worldocull.mm diff --git a/src/worldrender.cxx b/src/worldrender.mm similarity index 100% rename from src/worldrender.cxx rename to src/worldrender.mm