diff --git a/lib/ivis_common/imdload.c b/lib/ivis_common/imdload.c index 542136681..6b6b87f8f 100644 --- a/lib/ivis_common/imdload.c +++ b/lib/ivis_common/imdload.c @@ -475,9 +475,9 @@ static BOOL _imd_load_connectors(const char **ppFileData, iIMDShape *s) { const char *pFileData = *ppFileData; int cnt; - Vector3f *p = NULL, newVector = {0.0f, 0.0f, 0.0f}; + Vector3i *p = NULL, newVector = {0, 0, 0}; - s->connectors = (Vector3f*)malloc(sizeof(Vector3f) * s->nconnectors); + s->connectors = (Vector3i *)malloc(sizeof(Vector3i) * s->nconnectors); if (s->connectors == NULL) { debug(LOG_ERROR, "(_load_connectors) MALLOC fail"); @@ -486,7 +486,7 @@ static BOOL _imd_load_connectors(const char **ppFileData, iIMDShape *s) for (p = s->connectors; p < s->connectors + s->nconnectors; p++) { - if (sscanf(pFileData, "%f %f %f%n", &newVector.x, &newVector.y, &newVector.z, &cnt) != 3) + if (sscanf(pFileData, "%d %d %d%n", &newVector.x, &newVector.y, &newVector.z, &cnt) != 3) { debug(LOG_ERROR, "(_load_connectors) file corrupt -M"); return false; diff --git a/lib/ivis_common/ivisdef.h b/lib/ivis_common/ivisdef.h index a6b6e0e07..4bbc97e41 100644 --- a/lib/ivis_common/ivisdef.h +++ b/lib/ivis_common/ivisdef.h @@ -90,7 +90,7 @@ typedef struct _iIMDShape { iIMDPoly *polys; unsigned int nconnectors; - Vector3f *connectors; + Vector3i *connectors; unsigned int nShadowEdges; EDGE *shadowEdgeList; diff --git a/lib/ivis_opengl/piematrix.c b/lib/ivis_opengl/piematrix.c index d3dcafca1..e61746015 100644 --- a/lib/ivis_opengl/piematrix.c +++ b/lib/ivis_opengl/piematrix.c @@ -124,7 +124,7 @@ void pie_MATTRANS(float x, float y, float z) glLoadMatrixf(matrix); } -void pie_TRANSLATE(float x, float y, float z) +void pie_TRANSLATE(int32_t x, int32_t y, int32_t z) { /* * curMatrix = curMatrix . translationMatrix(x, y, z) diff --git a/lib/ivis_opengl/piematrix.h b/lib/ivis_opengl/piematrix.h index 87206b988..7d8eec072 100644 --- a/lib/ivis_opengl/piematrix.h +++ b/lib/ivis_opengl/piematrix.h @@ -89,7 +89,7 @@ extern void pie_MatInit(void); extern void pie_MatBegin(void); extern void pie_MatEnd(void); extern void pie_MATTRANS(float x, float y, float z); -extern void pie_TRANSLATE(float x, float y, float z); +extern void pie_TRANSLATE(int32_t x, int32_t y, int32_t z); extern void pie_MatScale(float scale); extern void pie_MatRotX(uint16_t x); extern void pie_MatRotY(uint16_t y); diff --git a/src/droid.c b/src/droid.c index b0958edf6..765872398 100644 --- a/src/droid.c +++ b/src/droid.c @@ -3047,6 +3047,8 @@ bool calcDroidMuzzleLocation(DROID *psDroid, Vector3i *muzzle, int weapon_slot) if (psBodyImd && psBodyImd->nconnectors) { + char debugStr[250], debugLen = 0; // Each "(%d,%d,%d)" uses up to 34 bytes, for very large values. So 250 isn't exaggerating. + Vector3i barrel = {0, 0, 0}; iIMDShape *psWeaponImd = 0, *psMountImd = 0; @@ -3066,6 +3068,7 @@ bool calcDroidMuzzleLocation(DROID *psDroid, Vector3i *muzzle, int weapon_slot) pie_MatRotZ(-psDroid->rot.roll); pie_TRANSLATE(psBodyImd->connectors[weapon_slot].x, -psBodyImd->connectors[weapon_slot].z, -psBodyImd->connectors[weapon_slot].y);//note y and z flipped + debugLen += sprintf(debugStr + debugLen, "connect:body[%d]=(%d,%d,%d)", weapon_slot, psBodyImd->connectors[weapon_slot].x, -psBodyImd->connectors[weapon_slot].z, -psBodyImd->connectors[weapon_slot].y); //matrix = the weapon[slot] mount on the body pie_MatRotY(psDroid->asWeaps[weapon_slot].rot.direction); // +ve anticlockwise @@ -3074,6 +3077,7 @@ bool calcDroidMuzzleLocation(DROID *psDroid, Vector3i *muzzle, int weapon_slot) if (psMountImd && psMountImd->nconnectors) { pie_TRANSLATE(psMountImd->connectors->x, -psMountImd->connectors->z, -psMountImd->connectors->y); + debugLen += sprintf(debugStr + debugLen, ",turret=(%d,%d,%d)", psMountImd->connectors->x, -psMountImd->connectors->z, -psMountImd->connectors->y); } //matrix = the turret connector for the gun @@ -3094,10 +3098,14 @@ bool calcDroidMuzzleLocation(DROID *psDroid, Vector3i *muzzle, int weapon_slot) barrel = Vector3i_Init(psWeaponImd->connectors[connector_num].x, -psWeaponImd->connectors[connector_num].y, -psWeaponImd->connectors[connector_num].z); + debugLen += sprintf(debugStr + debugLen, ",barrel[%u]=(%d,%d,%d)", connector_num, psWeaponImd->connectors[connector_num].x, -psWeaponImd->connectors[connector_num].y, -psWeaponImd->connectors[connector_num].z); } pie_RotateTranslate3i(&barrel, muzzle); muzzle->z = -muzzle->z; + debugLen += sprintf(debugStr + debugLen, ",muzzle=(%d,%d,%d)", muzzle->x, muzzle->y, muzzle->z); + + syncDebug("%s", debugStr); pie_MatEnd(); }