From 6c3b569e66ebf63188ffea7460de03c5b13452cb Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Wed, 27 Sep 2006 04:56:18 +0000 Subject: [PATCH] - Fixed GCC compilation again. - PClass::StaticInit() now sorts the class metadata so that operations that iterate over it (such as the "give all" cheat) are compiler-independant. SVN r340 (trunk) --- docs/rh-log.txt | 4 ++++ src/dobject.h | 3 +++ src/dobjtype.cpp | 22 ++++++++++++++++++++++ src/r_plane.cpp | 8 +++++++- 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 898f922cd..916120df4 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +September 26, 2006 +- PClass::StaticInit() now sorts the class metadata so that operations that + iterate over it (such as the "give all" cheat) are compiler-independant. + September 25, 2006 (Changes by Graf Zahl) - Fixed: ACustomInventory::CallStateChain couldn't be called recursively so any item that was giving another CustomInventory item didn't work diff --git a/src/dobject.h b/src/dobject.h index 2cc781884..df26756e9 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -38,6 +38,9 @@ #include "tarray.h" #include "doomtype.h" #include "m_alloc.h" +#ifndef _MSC_VER +#include "autosegs.h" +#endif struct PClass; diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 63647942c..0f5542671 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -2,6 +2,7 @@ #include "i_system.h" #include "actor.h" #include "autosegs.h" +#include "templates.h" TArray PClass::m_RuntimeActors; TArray PClass::m_Types; @@ -10,10 +11,31 @@ PClass *PClass::TypeHash[PClass::HASH_SIZE]; // A harmless non_NULL FlatPointer for classes without pointers. static const size_t TheEnd = ~0; +static int STACK_ARGS cregcmp (const void *a, const void *b) +{ + // VC++ introduces NULLs in the sequence. GCC seems to work as expected and not do it. + const ClassReg *class1 = *(const ClassReg **)a; + const ClassReg *class2 = *(const ClassReg **)b; + if (class1 == NULL) return 1; + if (class2 == NULL) return -1; + return strcmp (class1->Name, class2->Name); +} + void PClass::StaticInit () { atterm (StaticShutdown); + // Sort classes by name to remove dependance on how the compiler ordered them. + REGINFO *head = &CRegHead; + REGINFO *tail = &CRegTail; + + // MinGW's linker is linking the object files backwards for me now... + if (head > tail) + { + swap (head, tail); + } + qsort (head + 1, tail - head - 1, sizeof(REGINFO), cregcmp); + TAutoSegIterator probe; while (++probe != NULL) diff --git a/src/r_plane.cpp b/src/r_plane.cpp index ee25f2c53..844834d2d 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1470,8 +1470,14 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool masked) pviewy = MulScale (pl->yoffs, pl->yscale, ds_ybits); ang = (ANG270 - viewangle) >> ANGLETOFINESHIFT; +// Printf ("%u %d %d\n", ang, finecosine[ang], finesine[ang]); p[0] = FIXED2FLOAT(DMulScale16 (viewx, finecosine[ang], -viewy, finesine[ang])); p[2] = FIXED2FLOAT(DMulScale16 (viewx, finesine[ang], viewy, finecosine[ang])); +// double dang = 1.5*M_PI - double(viewangle)*M_PI/2147483648.0; +// double vx = viewx/65536.0, vy = viewy/65536.0; +// double dcos = cos(dang), dsin = sin(dang); +// p[0] = vx * dcos - vy * dsin; +// p[2] = vx * dsin + vy * dcos; p[1] = FIXED2FLOAT(pl->height.ZatPoint (0, 0) - viewz); // m is the v direction vector in view space @@ -1671,7 +1677,7 @@ bool R_AlignFlat (int linenum, int side, int fc) angle_t angle = R_PointToAngle2 (x, y, line->v2->x, line->v2->y); angle_t norm = (angle-ANGLE_90) >> ANGLETOFINESHIFT; - fixed_t dist = -FixedMul (finecosine[norm], x) - FixedMul (finesine[norm], y); + fixed_t dist = -DMulScale16 (finecosine[norm], x, finesine[norm], y); if (side) {