From 4babc4e4c993c45a33264d6c732a895055524203 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 20 Jan 2010 08:05:55 +0000 Subject: [PATCH] http://bugs.eressea.de/view.php?id=1697 - fixed bug that caused coordinates in planes to be adjusted in the wrong way. --- src/common/gamecode/creport.c | 18 ++++++++++++------ src/common/gamecode/report.c | 3 ++- src/common/gamecode/xmlreport.c | 4 +++- src/common/kernel/plane.c | 28 ---------------------------- src/common/kernel/plane.h | 2 -- src/common/kernel/region.c | 3 ++- src/common/kernel/ship.c | 1 + src/common/triggers/changerace.c | 3 +-- src/eressea.sln | 10 +++++++++- src/eressea/eressea-lua.vcproj | 2 +- src/eressea/tolua/bindings.c | 4 ++-- 11 files changed, 33 insertions(+), 45 deletions(-) diff --git a/src/common/gamecode/creport.c b/src/common/gamecode/creport.c index 4e3c7f539..be3de1950 100644 --- a/src/common/gamecode/creport.c +++ b/src/common/gamecode/creport.c @@ -310,8 +310,9 @@ cr_region(variant var, char * buffer, const void * userdata) region * r = (region *)var.v; if (r) { plane * pl = rplane(r); - int nx = region_x(r, report), ny = region_y(r, report); + int nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); + adjust_coordinates(report, &nx, &ny, pl, r); sprintf(buffer, "%d %d %d", nx, ny, plane_id(pl)); return 0; } @@ -424,9 +425,10 @@ cr_regions(variant var, char * buffer, const void * userdata) plane * pl = rplane(r); int i, z = plane_id(pl); char * wp = buffer; - int nx = region_x(r, f), ny = region_y(r, f); + int nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); + adjust_coordinates(f, &nx, &ny, pl, r); wp += sprintf(wp, "\"%d %d %d", nx, ny, z); for (i=1;i!=rdata->nregions;++i) { r = rdata->regions[i]; @@ -1147,9 +1149,9 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr) nx = r->x; ny = r->y; } else { - nx = region_x(r, f); - ny = region_y(r, f); + nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); + adjust_coordinates(f, &nx, &ny, pl, r); } if (pl) { @@ -1278,8 +1280,10 @@ cr_output_region(FILE * F, report_context * ctx, seen_region * sr) region_list *rl2 = rl; while(rl2) { region * r = rl2->data; - int nx = region_x(r, f), ny = region_y(r, f); + int nx = r->x, ny = r->y; + pnormalize(&nx, &ny, pl); + adjust_coordinates(f, &nx, &ny, pl, r); fprintf(F, "SCHEMEN %d %d\n", nx, ny); fprintf(F, "\"%s\";Name\n", rname(r, f->locale)); rl2 = rl2->next; @@ -1481,9 +1485,11 @@ report_computer(const char * filename, report_context * ctx, const char * charse for (bm=f->battles;bm;bm=bm->next) { plane * pl = rplane(bm->r); int plid = plane_id(pl); - int nx = region_x(bm->r, f), ny = region_y(bm->r, f); + region * r = bm->r; + int nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); + adjust_coordinates(f, &nx, &ny, pl, r); if (!plid) fprintf(F, "BATTLE %d %d\n", nx, ny); else { fprintf(F, "BATTLE %d %d %d\n", nx, ny, plid); diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index e289ca5be..ca77279fc 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -1409,9 +1409,10 @@ report_template(const char * filename, report_context * ctx, const char * charse order * ord; if (!dh) { plane * pl = getplane(r); - int nx = region_x(r, f), ny = region_y(r, f); + int nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); + adjust_coordinates(f, &nx, &ny, pl, r); rps_nowrap(F, ""); rnl(F); if (pl && pl->id != 0) { diff --git a/src/common/gamecode/xmlreport.c b/src/common/gamecode/xmlreport.c index 93f526c8d..237b4f6ce 100644 --- a/src/common/gamecode/xmlreport.c +++ b/src/common/gamecode/xmlreport.c @@ -593,8 +593,10 @@ xml_region(report_context * ctx, seen_region * sr) ship * sh = r->ships; building * b = r->buildings; plane * pl = rplane(r); - int nx = region_x(r, ctx->f), ny = region_y(r, ctx->f); + int nx = r->x, ny = r->y; + pnormalize(&nx, &ny, pl); + adjust_coordinates(ctx->f, &nx, &ny, pl, r); /* TODO: entertain-quota, recruits, salary, prices, curses, borders, apparitions (Schemen), spells, travelthru, messages */ xmlNewNsProp(node, xct->ns_xml, XML_XML_ID, xml_ref_region(r)); diff --git a/src/common/kernel/plane.c b/src/common/kernel/plane.c index e74089bce..d7152d345 100644 --- a/src/common/kernel/plane.c +++ b/src/common/kernel/plane.c @@ -190,34 +190,6 @@ plane_center_y(const plane *pl) return(pl->miny + pl->maxy)/2; } -int -region_x(const region *r, const faction *f) -{ - plane *pl = rplane(r); - int x = r->x - plane_center_x(pl); - if (f) { - int width = plane_width(pl); - int width_2 = width/2; - x -= ursprung_x(f, pl, r); - if (x>width_2) x -= width; - } - return x; -} - -int -region_y(const region *r, const faction *f) -{ - plane *pl = rplane(r); - int y = r->y - plane_center_y(pl); - if (f) { - int height = plane_height(pl); - int height_2 = height/2; - y -= ursprung_y(f, pl, r); - if (y>height_2) y -= height; - } - return y; -} - void adjust_coordinates(const faction *f, int *x, int *y, const plane * pl, const region * r) { diff --git a/src/common/kernel/plane.h b/src/common/kernel/plane.h index 00eb89ca7..e7223a251 100644 --- a/src/common/kernel/plane.h +++ b/src/common/kernel/plane.h @@ -66,8 +66,6 @@ struct plane *findplane(int x, int y); void init_planes(void); int getplaneid(const struct region *r); struct plane * getplanebyid(int id); -int region_x(const struct region *r, const struct faction *f); -int region_y(const struct region *r, const struct faction *f); int plane_center_x(const struct plane *pl); int plane_center_y(const struct plane *pl); void set_ursprung(struct faction *f, int id, int x, int y); diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 07d0f0794..20c5f57df 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -119,8 +119,9 @@ write_regionname(const region * r, const faction * f, char * buffer, size_t size strcpy(buf, "(null)"); } else { plane * pl = rplane(r); - int nx = region_x(r, f), ny = region_y(r, f); + int nx = r->x, ny = r->y; pnormalize(&nx, &ny, pl); + adjust_coordinates(f, &nx, &ny, pl, r); snprintf(buf, size, "%s (%d,%d)", rname(r, lang), nx, ny); } buf[size-1] = 0; diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index d8fd4bac3..320215942 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -36,6 +36,7 @@ /* libc includes */ #include +#include #include #include diff --git a/src/common/triggers/changerace.c b/src/common/triggers/changerace.c index 37f12d55f..fa563b4a4 100644 --- a/src/common/triggers/changerace.c +++ b/src/common/triggers/changerace.c @@ -105,11 +105,10 @@ trigger_type tt_changerace = { trigger * trigger_changerace(struct unit * u, const struct race * prace, const struct race * irace) { - const race * uirace = u_irace(u); trigger * t = t_new(&tt_changerace); changerace_data * td = (changerace_data*)t->data.v; - assert(u->race==uirace || "!changerace-triggers cannot stack!"); + assert(u->race==u_irace(u) || "!changerace-triggers cannot stack!"); td->u = u; td->race = prace; td->irace = irace; diff --git a/src/eressea.sln b/src/eressea.sln index 32598fa52..ba0219565 100644 --- a/src/eressea.sln +++ b/src/eressea.sln @@ -11,6 +11,12 @@ EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "common\util.vcproj", "{F70CFB27-8A2F-E447-B452-4E1C590EDA6D}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "eressea-lua", "eressea\eressea-lua.vcproj", "{75501170-51C2-E641-BA8B-EDC008184192}" + ProjectSection(ProjectDependencies) = postProject + {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D} = {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D} + {F70CFB27-8A2F-E447-B452-4E1C590EDA6D} = {F70CFB27-8A2F-E447-B452-4E1C590EDA6D} + {1E8BFF9E-3044-0742-992F-C5765B80FE65} = {1E8BFF9E-3044-0742-992F-C5765B80FE65} + {D893D6B3-805D-9848-8EA4-CDA1B79151F6} = {D893D6B3-805D-9848-8EA4-CDA1B79151F6} + EndProjectSection EndProject Global GlobalSection(SubversionScc) = preSolution @@ -27,20 +33,22 @@ Global {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Profile|Win32.ActiveCfg = Profile|Win32 {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Profile|Win32.Build.0 = Profile|Win32 {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Release|Win32.ActiveCfg = Release|Win32 + {6F104C0A-DDF5-A34B-A89C-0DC278DCEF6D}.Release|Win32.Build.0 = Release|Win32 {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Debug|Win32.ActiveCfg = Debug|Win32 {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Profile|Win32.ActiveCfg = Profile|Win32 {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Profile|Win32.Build.0 = Profile|Win32 {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Release|Win32.ActiveCfg = Release|Win32 + {1E8BFF9E-3044-0742-992F-C5765B80FE65}.Release|Win32.Build.0 = Release|Win32 {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Debug|Win32.ActiveCfg = Debug|Win32 {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Profile|Win32.ActiveCfg = Profile|Win32 {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Profile|Win32.Build.0 = Profile|Win32 {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Release|Win32.ActiveCfg = Release|Win32 + {D893D6B3-805D-9848-8EA4-CDA1B79151F6}.Release|Win32.Build.0 = Release|Win32 {AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}.Debug|Win32.ActiveCfg = Debug|Win32 {AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}.Debug|Win32.Build.0 = Debug|Win32 {AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}.Profile|Win32.ActiveCfg = Release|Win32 {AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}.Profile|Win32.Build.0 = Release|Win32 {AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}.Release|Win32.ActiveCfg = Release|Win32 - {AD80EB0B-7CB4-42F2-9C95-8CCEF68DB387}.Release|Win32.Build.0 = Release|Win32 {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Debug|Win32.ActiveCfg = Debug|Win32 {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Profile|Win32.ActiveCfg = Profile|Win32 {F70CFB27-8A2F-E447-B452-4E1C590EDA6D}.Profile|Win32.Build.0 = Profile|Win32 diff --git a/src/eressea/eressea-lua.vcproj b/src/eressea/eressea-lua.vcproj index 1511b1e2a..cdff8647a 100644 --- a/src/eressea/eressea-lua.vcproj +++ b/src/eressea/eressea-lua.vcproj @@ -210,7 +210,7 @@