ref: b15b45137188816b2bceecd1844c23c9b678e5d3
parent: 18337d7e1454d9ef237e3715f52a1526ec659002
author: qwx <qwx@sciops.net>
date: Thu Mar 25 20:01:02 EDT 2021
rename terrain → tile
--- a/dat.h
+++ b/dat.h
@@ -7,7 +7,7 @@
typedef struct Path Path;
typedef struct Mobj Mobj;
typedef struct Mobjl Mobjl;
-typedef struct Terrain Terrain;
+typedef struct Tile Tile;
typedef struct Map Map;
typedef struct Resource Resource;
typedef struct Team Team;
@@ -66,7 +66,7 @@
};
enum{
- PFterrain = 1<<0,
+ PFtile = 1<<0,
PFidle = 1<<1,
PFmove = 1<<2,
PFglow = 1<<13,
@@ -162,11 +162,11 @@
Mobjl *lp;
};
-struct Terrain{
+struct Tile{
Pic *p;
};
-extern Terrain **terrain;
-extern terwidth, terheight;
+extern Tile **tilemap;
+extern tilemapwidth, tilemapheight;
struct Map{
Mobjl ml;
--- a/drw.c
+++ b/drw.c
@@ -301,7 +301,7 @@
{
int x, y;
Rectangle mr, tr;
- Terrain **t;
+ Tile **t;
Map *m;
Mobj *mo;
Mobjl *ml;
@@ -311,20 +311,20 @@
tr.min.y = pan.y / scale / Tileheight;
tr.max.x = tr.min.x + (pan.x / scale % Tilewidth != 0);
tr.max.x += fbw / Tilewidth + (fbw % Tilewidth != 0);
- if(tr.max.x > terwidth)
- tr.max.x = terwidth;
+ if(tr.max.x > tilemapwidth)
+ tr.max.x = tilemapwidth;
tr.max.y = tr.min.y + (pan.y / scale % Tileheight != 0);
tr.max.y += fbh / Tileheight + (fbh % Tilewidth != 0);
- if(tr.max.y > terheight)
- tr.max.y = terheight;
+ if(tr.max.y > tilemapheight)
+ tr.max.y = tilemapheight;
mr.min.x = max(tr.min.x - 3, 0) * Node2Tile;
mr.min.y = max(tr.min.y - 3, 0) * Node2Tile;
mr.max.x = tr.max.x * Node2Tile;
mr.max.y = tr.max.y * Node2Tile;
- for(y=tr.min.y, t=terrain+y*terwidth+tr.min.x; y<tr.max.y; y++){
+ for(y=tr.min.y, t=tilemap+y*tilemapwidth+tr.min.x; y<tr.max.y; y++){
for(x=tr.min.x; x<tr.max.x; x++, t++)
drawpic(x*Tilewidth, y*Tileheight, (*t)->p, -1);
- t += terwidth - (tr.max.x - tr.min.x);
+ t += tilemapwidth - (tr.max.x - tr.min.x);
}
for(y=mr.min.y, m=map+y*mapwidth+mr.min.x; y<mr.max.y; y++){
for(x=mr.min.x; x<mr.max.x; x++, m++){
--- a/fs.c
+++ b/fs.c
@@ -11,7 +11,7 @@
typedef struct Table Table;
typedef struct Objp Objp;
typedef struct Picl Picl;
-typedef struct Terrainl Terrainl;
+typedef struct Tilel Tilel;
struct Objp{
Obj *o;
int team;
@@ -35,12 +35,12 @@
Pic *p;
Picl *l;
};
-struct Terrainl{
+struct Tilel{
int id;
- Terrain *t;
- Terrainl *l;
+ Tile *t;
+ Tilel *l;
};
-static Terrainl terrainl0 = {.l = &terrainl0}, *terrainl = &terrainl0;
+static Tilel tilel0 = {.l = &tilel0}, *tilel = &tilel0;
static Pic tilesetpic;
static Picl pic0 = {.l = &pic0}, *pic = &pic0;
static Objp *objp;
@@ -127,7 +127,7 @@
}
static void
-loadterpic(Pic *pic, Picl *pl)
+loadtilepic(Pic *pic, Picl *pl)
{
int id, size;
char path[128];
@@ -136,13 +136,13 @@
snprint(path, sizeof path, "%s.bit", tileset);
loadpic(path, &tilesetpic, 0);
if(tilesetpic.h % tilesetpic.w != 0)
- sysfatal("loadterpic: tiles not squares: tilepic %d,%d",
+ sysfatal("loadtilepic: tiles not squares: tilepic %d,%d",
tilesetpic.w, tilesetpic.h);
}
id = pl->frm;
size = tilesetpic.w;
if(size * id >= tilesetpic.h)
- sysfatal("loadterpic: terrain tile index %d out of bounds", id);
+ sysfatal("loadtilepic: tile tile index %d out of bounds", id);
pic->w = size;
pic->h = size;
size *= size;
@@ -158,8 +158,8 @@
for(pl=pic->l; pl!=pic; pl=pic->l){
p = pl->p;
- if(pl->type & PFterrain)
- loadterpic(p, pl);
+ if(pl->type & PFtile)
+ loadtilepic(p, pl);
else if(pl->type & PFshadow)
loadobjpic(p, pl, ".s");
else if(pl->type & PFglow)
@@ -205,21 +205,21 @@
return pl->p;
}
-static Terrain *
-pushterrain(int id)
+static Tile *
+pushtile(int id)
{
- Terrainl *tl;
+ Tilel *tl;
- for(tl=terrainl->l; tl!=terrainl; tl=tl->l)
+ for(tl=tilel->l; tl!=tilel; tl=tl->l)
if(tl->id == id)
break;
- if(tl == terrainl){
+ if(tl == tilel){
tl = emalloc(sizeof *tl);
tl->id = id;
tl->t = emalloc(sizeof *tl->t);
- tl->t->p = pushpic("/tile/", id - 1, PFterrain, 1, 0);
- tl->l = terrainl->l;
- terrainl->l = tl;
+ tl->t->p = pushpic("/tile/", id - 1, PFtile, 1, 0);
+ tl->l = tilel->l;
+ tilel->l = tl;
}
return tl->t;
}
@@ -288,10 +288,10 @@
case 't':
s = *fld++;
if(*s == 0)
- sysfatal("vunpack: empty terrain");
+ sysfatal("vunpack: empty tile");
if((n = strtol(s, nil, 0)) <= 0)
- sysfatal("vunpack: illegal terrain index %d", n);
- *va_arg(a, Terrain**) = pushterrain(n);
+ sysfatal("vunpack: illegal tile index %d", n);
+ *va_arg(a, Tile**) = pushtile(n);
break;
}
}
@@ -333,14 +333,14 @@
readmap(char **fld, int n, Table *tab)
{
int x;
- Terrain **t;
+ Tile **t;
if(tab->row == 0){
tab->ncol = n;
- terwidth = n;
- terrain = emalloc(terheight * terwidth * sizeof *terrain);
+ tilemapwidth = n;
+ tilemap = emalloc(tilemapheight * tilemapwidth * sizeof *tilemap);
}
- t = terrain + tab->row * terwidth;
+ t = tilemap + tab->row * tilemapwidth;
for(x=0; x<n; x++, t++)
unpack(fld++, "t", t);
}
@@ -435,7 +435,7 @@
sysfatal("readspr %s: pic type %#ux already allocated", o->name, type);
if(ps->nf != 0 && ps->nf != n || ps->nr != 0 && ps->nr != nr)
sysfatal("readspr %s: spriteset phase error", o->name);
- ps->teamcol = (type & (PFshadow|PFterrain|PFglow)) == 0;
+ ps->teamcol = (type & (PFshadow|PFtile|PFglow)) == 0;
ps->nf = n;
ps->nr = nr;
p = emalloc(n * sizeof *ppp);
@@ -463,7 +463,7 @@
[Tresource] {"resource", readresource, 2, &nresource},
[Tspawn] {"spawn", readspawn, -1, nil},
[Ttileset] {"tileset", readtileset, 1, nil},
- [Tmap] {"map", readmap, -1, &terheight},
+ [Tmap] {"map", readmap, -1, &tilemapheight},
[Tspr] {"spr", readspr, -1, nil},
};
@@ -554,10 +554,10 @@
static void
cleanup(void)
{
- Terrainl *tl;
+ Tilel *tl;
- for(tl=terrainl->l; tl!=terrainl; tl=terrainl->l){
- terrainl->l = tl->l;
+ for(tl=tilel->l; tl!=tilel; tl=tilel->l){
+ tilel->l = tl->l;
free(tl);
}
}
@@ -596,9 +596,9 @@
sysfatal("checkdb: no tileset defined");
if(nresource != Nresource)
sysfatal("checkdb: incomplete resource specification");
- if(terwidth % 16 != 0 || terheight % 16 != 0 || terwidth * terheight == 0)
+ if(tilemapwidth % 16 != 0 || tilemapheight % 16 != 0 || tilemapwidth * tilemapheight == 0)
sysfatal("checkdb: map size %d,%d not in multiples of 16",
- terwidth, terheight);
+ tilemapwidth, tilemapheight);
if(nteam < 2)
sysfatal("checkdb: not enough teams");
}
--- a/map.c
+++ b/map.c
@@ -4,8 +4,8 @@
#include "dat.h"
#include "fns.h"
-Terrain **terrain;
-int terwidth, terheight;
+Tile **tilemap;
+int tilemapwidth, tilemapheight;
Map *map;
int mapwidth, mapheight;
Node *node;
@@ -87,7 +87,7 @@
Mobj *mo;
if(o->f & Fbuild && (x & Node2Tile-1 || y & Node2Tile-1)){
- werrstr("mapspawn: building spawn %d,%d not aligned to terrain map", x, y);
+ werrstr("mapspawn: building spawn %d,%d not aligned to tile map", x, y);
return nil;
}
if(getspawn(&x, &y, o) < 0)
@@ -113,8 +113,8 @@
int n;
Map *m;
- mapwidth = terwidth * Node2Tile;
- mapheight = terheight * Node2Tile;
+ mapwidth = tilemapwidth * Node2Tile;
+ mapheight = tilemapheight * Node2Tile;
n = mapwidth * mapheight;
map = emalloc(n * sizeof *map);
node = emalloc(n * sizeof *node);