forked from github/server
calling getplane() and rplane() is a real waste of cycles (and happens enough to shortcut it)
This commit is contained in:
parent
fc121f99a6
commit
07ecc3e517
|
@ -327,7 +327,7 @@ cr_region(variant var, char * buffer, const void * userdata)
|
||||||
const faction * report = (const faction*)userdata;
|
const faction * report = (const faction*)userdata;
|
||||||
region * r = (region *)var.v;
|
region * r = (region *)var.v;
|
||||||
if (r) {
|
if (r) {
|
||||||
plane * p = rplane(r);
|
plane * p = r->planep;
|
||||||
if (!p || !(p->flags & PFL_NOCOORDS)) {
|
if (!p || !(p->flags & PFL_NOCOORDS)) {
|
||||||
sprintf(buffer, "%d %d %d", region_x(r, report), region_y(r, report), p?p->id:0);
|
sprintf(buffer, "%d %d %d", region_x(r, report), region_y(r, report), p?p->id:0);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1203,10 +1203,10 @@ report_computer(const char * filename, report_context * ctx)
|
||||||
{
|
{
|
||||||
struct bmsg * bm;
|
struct bmsg * bm;
|
||||||
for (bm=f->battles;bm;bm=bm->next) {
|
for (bm=f->battles;bm;bm=bm->next) {
|
||||||
if (!rplane(bm->r)) fprintf(F, "BATTLE %d %d\n", region_x(bm->r, f), region_y(bm->r, f));
|
if (!bm->r->planep) fprintf(F, "BATTLE %d %d\n", region_x(bm->r, f), region_y(bm->r, f));
|
||||||
else {
|
else {
|
||||||
if (rplane(bm->r)->flags & PFL_NOCOORDS) fprintf(F, "BATTLESPEC %d %d\n", encode_region(f, bm->r), rplane(bm->r)->id);
|
if (bm->r->planep->flags & PFL_NOCOORDS) fprintf(F, "BATTLESPEC %d %d\n", encode_region(f, bm->r), bm->r->planep->id);
|
||||||
else fprintf(F, "BATTLE %d %d %d\n", region_x(bm->r, f), region_y(bm->r, f), rplane(bm->r)->id);
|
else fprintf(F, "BATTLE %d %d %d\n", region_x(bm->r, f), region_y(bm->r, f), bm->r->planep->id);
|
||||||
}
|
}
|
||||||
cr_output_messages(F, bm->msgs, f);
|
cr_output_messages(F, bm->msgs, f);
|
||||||
}
|
}
|
||||||
|
@ -1255,7 +1255,7 @@ report_computer(const char * filename, report_context * ctx)
|
||||||
region * r = sr->r;
|
region * r = sr->r;
|
||||||
const char * tname;
|
const char * tname;
|
||||||
|
|
||||||
if (!rplane(r)) {
|
if (!r->planep) {
|
||||||
if (opt_cr_absolute_coords) {
|
if (opt_cr_absolute_coords) {
|
||||||
fprintf(F, "REGION %d %d\n", r->x, r->x);
|
fprintf(F, "REGION %d %d\n", r->x, r->x);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1263,11 +1263,11 @@ report_computer(const char * filename, report_context * ctx)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if ENCODE_SPECIAL
|
#if ENCODE_SPECIAL
|
||||||
if (rplane(r)->flags & PFL_NOCOORDS) fprintf(F, "SPEZIALREGION %d %d\n", encode_region(f, r), rplane(r)->id);
|
if (r->planep->flags & PFL_NOCOORDS) fprintf(F, "SPEZIALREGION %d %d\n", encode_region(f, r), r->planep->id);
|
||||||
#else
|
#else
|
||||||
if (rplane(r)->flags & PFL_NOCOORDS) continue;
|
if (r->planep->flags & PFL_NOCOORDS) continue;
|
||||||
#endif
|
#endif
|
||||||
else fprintf(F, "REGION %d %d %d\n", region_x(r, f), region_y(r, f), rplane(r)->id);
|
else fprintf(F, "REGION %d %d %d\n", region_x(r, f), region_y(r, f), r->planep->id);
|
||||||
}
|
}
|
||||||
if (r->land && strlen(rname(r, f->locale))) fprintf(F, "\"%s\";Name\n", rname(r, f->locale));
|
if (r->land && strlen(rname(r, f->locale))) fprintf(F, "\"%s\";Name\n", rname(r, f->locale));
|
||||||
if (is_cursed(r->attribs,C_MAELSTROM, 0))
|
if (is_cursed(r->attribs,C_MAELSTROM, 0))
|
||||||
|
@ -1384,7 +1384,7 @@ report_computer(const char * filename, report_context * ctx)
|
||||||
}
|
}
|
||||||
print_curses(F, f, r, TYP_REGION);
|
print_curses(F, f, r, TYP_REGION);
|
||||||
cr_borders(ctx->seen, r, f, sr->mode, F);
|
cr_borders(ctx->seen, r, f, sr->mode, F);
|
||||||
if (sr->mode==see_unit && rplane(r)==get_astralplane() && !is_cursed(r->attribs, C_ASTRALBLOCK, 0))
|
if (sr->mode==see_unit && r->planep==get_astralplane() && !is_cursed(r->attribs, C_ASTRALBLOCK, 0))
|
||||||
{
|
{
|
||||||
/* Sonderbehandlung Teleport-Ebene */
|
/* Sonderbehandlung Teleport-Ebene */
|
||||||
region_list *rl = astralregions(r, inhabitable);
|
region_list *rl = astralregions(r, inhabitable);
|
||||||
|
@ -1477,7 +1477,7 @@ crwritemap(const char * filename)
|
||||||
FILE * F = fopen(filename, "w+");
|
FILE * F = fopen(filename, "w+");
|
||||||
region * r;
|
region * r;
|
||||||
for (r=regions;r;r=r->next) {
|
for (r=regions;r;r=r->next) {
|
||||||
plane * p = rplane(r);
|
plane * p = r->planep;
|
||||||
fprintf(F, "REGION %d %d %d\n", r->x, r->y, p?p->id:0);
|
fprintf(F, "REGION %d %d %d\n", r->x, r->y, p?p->id:0);
|
||||||
fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale), LOC(default_locale, terrain_name(r)));
|
fprintf(F, "\"%s\";Name\n\"%s\";Terrain\n", rname(r, default_locale), LOC(default_locale, terrain_name(r)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -639,12 +639,11 @@ rp_battles(FILE * F, faction * f)
|
||||||
size_t
|
size_t
|
||||||
f_regionid(const region * r, const faction * f, char * buffer, size_t size)
|
f_regionid(const region * r, const faction * f, char * buffer, size_t size)
|
||||||
{
|
{
|
||||||
plane * pl = NULL;
|
|
||||||
|
|
||||||
if (!r) {
|
if (!r) {
|
||||||
strncpy(buffer, "(Chaos)", size);
|
strncpy(buffer, "(Chaos)", size);
|
||||||
} else {
|
} else {
|
||||||
pl = getplane(r);
|
plane * pl = r->planep;
|
||||||
strncpy(buffer, rname(r, f->locale), size);
|
strncpy(buffer, rname(r, f->locale), size);
|
||||||
buffer[size-1]=0;
|
buffer[size-1]=0;
|
||||||
if (pl==NULL || !fval(pl, PFL_NOCOORDS)) {
|
if (pl==NULL || !fval(pl, PFL_NOCOORDS)) {
|
||||||
|
|
|
@ -1002,7 +1002,7 @@ int
|
||||||
alliedunit(const unit * u, const faction * f2, int mode)
|
alliedunit(const unit * u, const faction * f2, int mode)
|
||||||
{
|
{
|
||||||
ally * sf;
|
ally * sf;
|
||||||
const plane * pl = getplane(u->region);
|
const plane * pl = u->region->planep;
|
||||||
int automode;
|
int automode;
|
||||||
|
|
||||||
if (u->faction == f2) return mode;
|
if (u->faction == f2) return mode;
|
||||||
|
|
|
@ -163,19 +163,15 @@ plane_center_y(const plane *pl)
|
||||||
short
|
short
|
||||||
region_x(const region *r, const faction *f)
|
region_x(const region *r, const faction *f)
|
||||||
{
|
{
|
||||||
plane *pl;
|
plane *pl = r->planep;
|
||||||
assert(r!=NULL);
|
return r->x - ursprung_x(f, pl, r) - plane_center_x(pl);
|
||||||
pl = getplane(r);
|
|
||||||
return r->x - ursprung_x(f, pl, r) - plane_center_x(pl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
short
|
short
|
||||||
region_y(const region *r, const faction *f)
|
region_y(const region *r, const faction *f)
|
||||||
{
|
{
|
||||||
plane *pl;
|
plane *pl = r->planep;
|
||||||
assert(r!=NULL);
|
return r->y - plane_center_y(pl) - ursprung_y(f, pl, r);
|
||||||
pl = getplane(r);
|
|
||||||
return r->y - plane_center_y(pl) - ursprung_y(f, pl, r);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -103,20 +103,22 @@ regionname(const region * r, const faction * f)
|
||||||
{
|
{
|
||||||
static char buf[65];
|
static char buf[65];
|
||||||
const struct locale * lang = f ? f->locale : 0;
|
const struct locale * lang = f ? f->locale : 0;
|
||||||
plane *pl = getplane(r);
|
|
||||||
if (r==NULL) {
|
if (r==NULL) {
|
||||||
strcpy(buf, "(null)");
|
strcpy(buf, "(null)");
|
||||||
} else if (pl && fval(pl, PFL_NOCOORDS)) {
|
|
||||||
strncpy(buf, rname(r, lang), 65);
|
|
||||||
} else {
|
} else {
|
||||||
|
plane *pl = r->planep;
|
||||||
|
if (pl && fval(pl, PFL_NOCOORDS)) {
|
||||||
|
strncpy(buf, rname(r, lang), 65);
|
||||||
|
} else {
|
||||||
#ifdef HAVE_SNPRINTF
|
#ifdef HAVE_SNPRINTF
|
||||||
snprintf(buf, 65, "%s (%d,%d)", rname(r, lang),
|
snprintf(buf, 65, "%s (%d,%d)", rname(r, lang),
|
||||||
region_x(r, f), region_y(r, f));
|
region_x(r, f), region_y(r, f));
|
||||||
#else
|
#else
|
||||||
strncpy(buf, rname(r, lang), 50);
|
strncpy(buf, rname(r, lang), 50);
|
||||||
buf[50]=0;
|
buf[50]=0;
|
||||||
sprintf(buf+strlen(buf), " (%d,%d)", region_x(r, f), region_y(r, f));
|
sprintf(buf+strlen(buf), " (%d,%d)", region_x(r, f), region_y(r, f));
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buf[64] = 0;
|
buf[64] = 0;
|
||||||
return buf;
|
return buf;
|
||||||
|
|
|
@ -664,7 +664,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode)
|
||||||
|
|
||||||
dh=0;
|
dh=0;
|
||||||
if (!getarnt && f) {
|
if (!getarnt && f) {
|
||||||
if (alliedfaction(getplane(u->region), f, fv, HELP_ALL)) {
|
if (alliedfaction(u->region->planep, f, fv, HELP_ALL)) {
|
||||||
dh = 1;
|
dh = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1185,7 +1185,7 @@ prepare_report(faction * f)
|
||||||
for (r = firstregion(f); r != end; r = r->next) {
|
for (r = firstregion(f); r != end; r = r->next) {
|
||||||
attrib *ru;
|
attrib *ru;
|
||||||
unit * u;
|
unit * u;
|
||||||
plane * p = rplane(r);
|
plane * p = r->planep;
|
||||||
unsigned char mode = see_none;
|
unsigned char mode = see_none;
|
||||||
boolean dis = false;
|
boolean dis = false;
|
||||||
int light = 0;
|
int light = 0;
|
||||||
|
|
|
@ -500,7 +500,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
|
||||||
* like the last land virgin ocean region adjacent to land.
|
* like the last land virgin ocean region adjacent to land.
|
||||||
*/
|
*/
|
||||||
for (r=regions;r;r=r->next) {
|
for (r=regions;r;r=r->next) {
|
||||||
struct plane * p = rplane(r);
|
struct plane * p = r->planep;
|
||||||
if (rterrain(r)==T_OCEAN && p==NULL && virgin_region(r)) {
|
if (rterrain(r)==T_OCEAN && p==NULL && virgin_region(r)) {
|
||||||
direction_t d;
|
direction_t d;
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
|
@ -546,7 +546,7 @@ autoseed(newfaction ** players, int nsize, boolean new_island)
|
||||||
* dmin = direction in which it's empty
|
* dmin = direction in which it's empty
|
||||||
*/
|
*/
|
||||||
for (r=regions;r;r=r->next) {
|
for (r=regions;r;r=r->next) {
|
||||||
struct plane * p = rplane(r);
|
struct plane * p = r->planep;
|
||||||
if (rterrain(r)==T_OCEAN && p==0 && (rmin==NULL || r->age<=MAXAGEDIFF)) {
|
if (rterrain(r)==T_OCEAN && p==0 && (rmin==NULL || r->age<=MAXAGEDIFF)) {
|
||||||
direction_t d;
|
direction_t d;
|
||||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||||
|
|
Loading…
Reference in New Issue