diff --git a/src/client.m b/src/Client.m similarity index 100% rename from src/client.m rename to src/Client.m diff --git a/src/clientextras.mm b/src/clientextras.m similarity index 100% rename from src/clientextras.mm rename to src/clientextras.m diff --git a/src/clientgame.mm b/src/clientgame.m similarity index 97% rename from src/clientgame.mm rename to src/clientgame.m index 6a394b5..a01d4fd 100644 --- a/src/clientgame.mm +++ b/src/clientgame.m @@ -9,7 +9,7 @@ int nextmode = 0; // nextmode becomes gamemode after next map load VAR(gamemode, 1, 0, 0); -void +static void mode(int n) { addmsg(1, 2, SV_GAMEMODE, nextmode = n); @@ -144,17 +144,17 @@ respawnself() showscores(false); } -void +static void arenacount( - DynamicEntity *d, int &alive, int &dead, OFString **lastteam, bool &oneteam) + DynamicEntity *d, int *alive, int *dead, OFString **lastteam, bool *oneteam) { if (d.state != CS_DEAD) { - alive++; + (*alive)++; if (![*lastteam isEqual:d.team]) - oneteam = false; + *oneteam = false; *lastteam = d.team; } else - dead++; + (*dead)++; } int arenarespawnwait = 0; @@ -177,8 +177,8 @@ arenarespawn() for (id player in players) if (player != [OFNull null]) arenacount( - player, alive, dead, &lastteam, oneteam); - arenacount(player1, alive, dead, &lastteam, oneteam); + player, &alive, &dead, &lastteam, &oneteam); + arenacount(player1, &alive, &dead, &lastteam, &oneteam); if (dead > 0 && (alive <= 1 || (m_teammode && oneteam))) { conoutf( @"arena round is over! next round in 5 seconds..."); @@ -332,7 +332,7 @@ spawnplayer(DynamicEntity *d) // movement input code #define dir(name, v, d, s, os) \ - void name(bool isdown) \ + static void name(bool isdown) \ { \ player1.s = isdown; \ player1.v = isdown ? d : (player1.os ? -(d) : 0); \ diff --git a/src/clients.mm b/src/clients.m similarity index 98% rename from src/clients.mm rename to src/clients.m index 995f900..b467568 100644 --- a/src/clients.mm +++ b/src/clients.m @@ -197,11 +197,9 @@ addmsg(int rel, int num, int type, ...) { if (demoplayback) return; - if (num != msgsizelookup(type)) { - fatal([OFString - stringWithFormat:@"inconsistant msg size for %d (%d != %d)", - type, num, msgsizelookup(type)]); - } + if (num != msgsizelookup(type)) + fatal(@"inconsistant msg size for %d (%d != %d)", type, num, + msgsizelookup(type)); if (messages.count == 100) { conoutf(@"command flood protection (type %d)", type); return; diff --git a/src/clients2c.mm b/src/clients2c.m similarity index 99% rename from src/clients2c.mm rename to src/clients2c.m index 06327ef..1372d29 100644 --- a/src/clients2c.mm +++ b/src/clients2c.m @@ -308,7 +308,7 @@ localservertoclient(uchar *buf, int len) int xs = getint(&p); int ys = getint(&p); int v = getint(&p); - block b = { x, y, xs, ys }; + struct block b = { x, y, xs, ys }; switch (type) { case SV_EDITH: editheightxy(v != 0, getint(&p), &b); diff --git a/src/console.mm b/src/console.m similarity index 100% rename from src/console.mm rename to src/console.m diff --git a/src/editing.mm b/src/editing.m similarity index 90% rename from src/editing.mm rename to src/editing.m index 0d7a047..76eced9 100644 --- a/src/editing.mm +++ b/src/editing.m @@ -12,12 +12,12 @@ bool editmode = false; // invariant: all code assumes that these are kept inside MINBORD distance of // the edge of the map -block sel; +struct block sel; OF_CONSTRUCTOR() { enqueueInit(^{ - sel = (block) { + sel = (struct block) { variable(@"selx", 0, 0, 4096, &sel.x, NULL, false), variable(@"sely", 0, 0, 4096, &sel.y, NULL, false), variable(@"selxs", 0, 0, 4096, &sel.xs, NULL, false), @@ -34,7 +34,7 @@ bool selset = false; makeundo(); \ loop(x, sel->xs) loop(y, sel->ys) \ { \ - sqr *s = S(sel->x + x, sel->y + y); \ + struct sqr *s = S(sel->x + x, sel->y + y); \ b; \ } \ remip(sel, 0); \ @@ -48,7 +48,7 @@ bool dragging = false; int lastx, lasty, lasth; int lasttype = 0, lasttex = 0; -sqr rtex; +static struct sqr rtex; VAR(editing, 0, 0, 1); @@ -121,7 +121,7 @@ noselection() void selectpos(int x, int y, int xs, int ys) { - block s = { x, y, xs, ys }; + struct block s = { x, y, xs, ys }; sel = s; selh = 0; correctsel(); @@ -130,7 +130,7 @@ selectpos(int x, int y, int xs, int ys) void makesel() { - block s = { min(lastx, cx), min(lasty, cy), abs(lastx - cx) + 1, + struct block s = { min(lastx, cx), min(lasty, cy), abs(lastx - cx) + 1, abs(lasty - cy) + 1 }; sel = s; selh = max(lasth, ch); @@ -141,9 +141,9 @@ makesel() VAR(flrceil, 0, 0, 2); +// finds out z height when cursor points at wall float -sheight( - sqr *s, sqr *t, float z) // finds out z height when cursor points at wall +sheight(struct sqr *s, struct sqr *t, float z) { return !flrceil // z-s->floorceil-z ? (s->type == FHF ? s->floor - t->vdelta / 4.0f : (float)s->floor) @@ -165,7 +165,7 @@ cursorupdate() // called every frame from hud if (OUTBORD(cx, cy)) return; - sqr *s = S(cx, cy); + struct sqr *s = S(cx, cy); // selected wall if (fabs(sheight(s, s, z) - z) > 1) { @@ -194,7 +194,7 @@ cursorupdate() // called every frame from hud for (int iy = cy - GRIDSIZE; iy <= cy + GRIDSIZE; iy++) { if (OUTBORD(ix, iy)) continue; - sqr *s = S(ix, iy); + struct sqr *s = S(ix, iy); if (SOLID(s)) continue; float h1 = sheight(s, s, z); @@ -207,7 +207,7 @@ cursorupdate() // called every frame from hud linestyle(GRIDW, 0x80, 0xFF, 0x80); else linestyle(GRIDW, 0x80, 0x80, 0x80); - block b = { ix, iy, 1, 1 }; + struct block b = { ix, iy, 1, 1 }; box(&b, h1, h2, h3, h4); linestyle(GRID8, 0x40, 0x40, 0xFF); if (!(ix & GRIDM)) @@ -224,7 +224,7 @@ cursorupdate() // called every frame from hud if (!SOLID(s)) { float ih = sheight(s, s, z); linestyle(GRIDS, 0xFF, 0xFF, 0xFF); - block b = { cx, cy, 1, 1 }; + struct block b = { cx, cy, 1, 1 }; box(&b, ih, sheight(s, SWS(s, 1, 0, ssize), z), sheight(s, SWS(s, 1, 1, ssize), z), sheight(s, SWS(s, 0, 1, ssize), z)); @@ -247,9 +247,9 @@ pruneundos(int maxremain) // bound memory { int t = 0; for (ssize_t i = (ssize_t)undos.count - 1; i >= 0; i--) { - block *undo = *(block **)[undos itemAtIndex:i]; + struct block *undo = [undos mutableItemAtIndex:i]; - t += undo->xs * undo->ys * sizeof(sqr); + t += undo->xs * undo->ys * sizeof(struct sqr); if (t > maxremain) { OFFreeMemory(undo); [undos removeItemAtIndex:i]; @@ -262,9 +262,9 @@ makeundo() { if (undos == nil) undos = - [[OFMutableData alloc] initWithItemSize:sizeof(block *)]; + [[OFMutableData alloc] initWithItemSize:sizeof(struct block *)]; - block *copy = blockcopy(&sel); + struct block *copy = blockcopy(&sel); [undos addItem:©]; pruneundos(undomegs << 20); } @@ -277,13 +277,13 @@ editundo() conoutf(@"nothing more to undo"); return; } - block *p = *(block **)undos.lastItem; + struct block *p = undos.mutableLastItem; [undos removeLastItem]; blockpaste(p); OFFreeMemory(p); } -block *copybuf = NULL; +static struct block *copybuf = NULL; void copy() @@ -351,7 +351,7 @@ editdrag(bool isDown) // strictly triggered locally. They all have very similar structure. void -editheightxy(bool isfloor, int amount, const block *sel) +editheightxy(bool isfloor, int amount, const struct block *sel) { loopselxy( if (isfloor) { @@ -376,7 +376,7 @@ editheight(int flr, int amount) COMMAND(editheight, ARG_2INT) void -edittexxy(int type, int t, const block *sel) +edittexxy(int type, int t, const struct block *sel) { loopselxy(switch (type) { case 0: @@ -419,7 +419,7 @@ replace() EDITSELMP; loop(x, ssize) loop(y, ssize) { - sqr *s = S(x, y); + struct sqr *s = S(x, y); switch (lasttype) { case 0: if (s->ftex == rtex.ftex) @@ -439,12 +439,12 @@ replace() break; } } - block b = { 0, 0, ssize, ssize }; + struct block b = { 0, 0, ssize, ssize }; remip(&b, 0); } void -edittypexy(int type, const block *sel) +edittypexy(int type, const struct block *sel) { loopselxy(s->type = type); } @@ -485,7 +485,7 @@ corner() COMMAND(corner, ARG_NONE) void -editequalisexy(bool isfloor, const block *sel) +editequalisexy(bool isfloor, const struct block *sel) { int low = 127, hi = -128; loopselxy({ @@ -515,7 +515,7 @@ equalize(int flr) COMMAND(equalize, ARG_1INT) void -setvdeltaxy(int delta, const block *sel) +setvdeltaxy(int delta, const struct block *sel) { loopselxy(s->vdelta = max(s->vdelta + delta, 0)); remipmore(sel, 0); @@ -555,9 +555,9 @@ arch(int sidedelta, int _a) sel.xs = MAXARCHVERT; if (sel.ys > MAXARCHVERT) sel.ys = MAXARCHVERT; - block *sel_ = &sel; + struct block *sel_ = &sel; // Ugly hack to make the macro work. - block *sel = sel_; + struct block *sel = sel_; loopselxy(s->vdelta = sel->xs > sel->ys ? (archverts[sel->xs - 1][x] + (y == 0 || y == sel->ys - 1 ? sidedelta : 0)) @@ -577,9 +577,9 @@ slope(int xd, int yd) off -= yd * sel.ys; sel.xs++; sel.ys++; - block *sel_ = &sel; + struct block *sel_ = &sel; // Ugly hack to make the macro work. - block *sel = sel_; + struct block *sel = sel_; loopselxy(s->vdelta = xd * x + yd * y + off); remipmore(sel, 0); } @@ -612,9 +612,9 @@ void edittag(int tag) { EDITSELMP; - block *sel_ = &sel; + struct block *sel_ = &sel; // Ugly hack to make the macro work. - block *sel = sel_; + struct block *sel = sel_; loopselxy(s->tag = tag); } diff --git a/src/entities.mm b/src/entities.m similarity index 95% rename from src/entities.mm rename to src/entities.m index 08c9c8e..8452b24 100644 --- a/src/entities.mm +++ b/src/entities.m @@ -29,9 +29,9 @@ initEntities() ents = [[OFMutableArray alloc] init]; } -void -renderent(Entity *e, OFString *mdlname, float z, float yaw, int frame = 0, - int numf = 1, int basetime = 0, float speed = 10.0f) +static void +renderent(Entity *e, OFString *mdlname, float z, float yaw, int frame/* = 0*/, + int numf/* = 1*/, int basetime/* = 0*/, float speed/* = 10.0f*/) { rendermodel(mdlname, frame, numf, 0, 1.1f, OFMakeVector3D(e.x, z + S(e.x, e.y)->floor, e.y), yaw, 0, false, @@ -67,7 +67,7 @@ renderentities() (float)(1 + sin(lastmillis / 100.0 + e.x + e.y) / 20), - lastmillis / 10.0f); + lastmillis / 10.0f, 0,1,0,10.0f); } else { switch (e.attr2) { case 1: @@ -84,7 +84,8 @@ renderentities() e.y) / 20), lastmillis / - (e.attr2 ? 1.0f : 10.0f)); + (e.attr2 ? 1.0f : 10.0f), + 0, 1, 0, 10.0f); break; case 4: @@ -136,12 +137,12 @@ baseammo(int gun) static int radditem(int i, int v) { - itemstat &is = itemstats[ents[i].type - I_SHELLS]; + struct itemstat *is = &itemstats[ents[i].type - I_SHELLS]; ents[i].spawned = false; - v += is.add; - if (v > is.max) - v = is.max; - playsoundc(is.sound); + v += is->add; + if (v > is->max) + v = is->max; + playsoundc(is->sound); return v; } diff --git a/src/menus.mm b/src/menus.m similarity index 100% rename from src/menus.mm rename to src/menus.m diff --git a/src/meson.build b/src/meson.build index fd8066a..1911c38 100644 --- a/src/meson.build +++ b/src/meson.build @@ -21,17 +21,17 @@ executable('client', 'ServerEntity.m', 'ServerInfo.m', 'Variable.m', - 'clients.mm', - 'clientextras.mm', - 'clientgame.mm', - 'clients2c.mm', + 'clients.m', + 'clientextras.m', + 'clientgame.m', + 'clients2c.m', 'commands.mm', - 'console.mm', - 'editing.mm', - 'entities.mm', + 'console.m', + 'editing.m', + 'entities.m', 'init.mm', - 'menus.mm', - 'monster.mm', + 'menus.m', + 'monster.m', 'physics.mm', 'rendercubes.mm', 'renderextras.mm', diff --git a/src/monster.mm b/src/monster.m similarity index 97% rename from src/monster.mm rename to src/monster.m index 12d6261..63191e4 100644 --- a/src/monster.mm +++ b/src/monster.m @@ -63,7 +63,7 @@ basicmonster(int type, int yaw, int state, int trigger, int move) type = 0; } DynamicEntity *m = newdynent(); - monstertype *t = &monstertypes[(m.mtype = type)]; + struct monstertype *t = &monstertypes[(m.mtype = type)]; m.eyeheight = 2.0f; m.aboveeye = 1.9f; m.radius *= t->bscale / 10.0f; @@ -138,7 +138,7 @@ monsterclear() // height-correct line of sight for monster shooting/seeing bool -los(float lx, float ly, float lz, float bx, float by, float bz, OFVector3D &v) +los(float lx, float ly, float lz, float bx, float by, float bz, OFVector3D *v) { if (OUTBORD((int)lx, (int)ly) || OUTBORD((int)bx, (int)by)) return false; @@ -151,7 +151,7 @@ los(float lx, float ly, float lz, float bx, float by, float bz, OFVector3D &v) float y = ly; int i = 0; for (;;) { - sqr *s = S(fast_f2nat(x), fast_f2nat(y)); + struct sqr *s = S(fast_f2nat(x), fast_f2nat(y)); if (SOLID(s)) break; float floor = s->floor; @@ -163,9 +163,9 @@ los(float lx, float ly, float lz, float bx, float by, float bz, OFVector3D &v) float rz = lz - ((lz - bz) * (i / (float)steps)); if (rz < floor || rz > ceil) break; - v.x = x; - v.y = y; - v.z = rz; + v->x = x; + v->y = y; + v->z = rz; x += dx / (float)steps; y += dy / (float)steps; i++; @@ -174,9 +174,9 @@ los(float lx, float ly, float lz, float bx, float by, float bz, OFVector3D &v) } bool -enemylos(DynamicEntity *m, OFVector3D &v) +enemylos(DynamicEntity *m, OFVector3D *v) { - v = m.o; + *v = m.o; return los( m.o.x, m.o.y, m.o.z, m.enemy.o.x, m.enemy.o.y, m.enemy.o.z, v); } @@ -261,7 +261,7 @@ monsteraction(DynamicEntity *m) // contact { OFVector3D target; - if (editmode || !enemylos(m, target)) + if (editmode || !enemylos(m, &target)) return; // skip running physics normalise(m, enemyyaw); float angle = (float)fabs(enemyyaw - m.yaw); @@ -295,7 +295,7 @@ monsteraction(DynamicEntity *m) m.targetyaw = enemyyaw; if (m.trigger < lastmillis) { OFVector3D target; - if (!enemylos(m, target)) { + if (!enemylos(m, &target)) { // no visual contact anymore, let monster get // as close as possible then search for player transition(m, M_HOME, 1, 800, 500); diff --git a/src/serverbrowser.mm b/src/serverbrowser.mm index 9bc0dcf..3995f91 100644 --- a/src/serverbrowser.mm +++ b/src/serverbrowser.mm @@ -202,7 +202,7 @@ checkpings() } } -void +extern "C" void refreshservers() { checkresolver();