Early pathfinding

svn-id: r30012
This commit is contained in:
Vincent Hamm 2007-12-27 12:05:43 +00:00
parent 410a4a974e
commit f953ed4dde
13 changed files with 209 additions and 324 deletions

View file

@ -68,40 +68,35 @@ int flag_aff_chemin;
void getPixel(int x, int y) { void getPixel(int x, int y) {
int x_min, x_max, y_min, y_max; int x_min, x_max, y_min, y_max;
ctpVar19Struct *polygone; int16* polygone = (int16*)polyStruct0;
ctpVar19SubStruct *tableau; int16* next;
polygone = ctpVar19; /* adr structure polygone */ while ((next = *(int16**)polygone) != (int16 *) -1) {
polygone+=sizeof(uint16*);
while (polygone->field_0 != (ctpVar19Struct *) - 1) { int16* tableau = polygone+2;
tableau = &polygone->subStruct;
x_min = tableau->minX; x_min = *tableau++;
x_max = tableau->maxX; x_max = *tableau++;
y_min = tableau->minY; y_min = *tableau++;
y_max = tableau->maxY; y_max = *tableau++;
computedVar14 = tableau->boxIdx; /* numero polygone */ computedVar14 = *polygone++;
if (walkboxChange[computedVar14] == 0 && ((x >= x_min if (walkboxState[computedVar14] == 0 && ((x >= x_min && x <= x_max) && (y >= y_min && y <= y_max))) {
&& x <= x_max) && (y >= y_min && y <= y_max))) {
// click was in given box // click was in given box
/* u = y-y_min; int u = y-y_min;
* tableau+=u*2;
* //tableau+=u; x_min = *tableau++;
* tableau = &polygone[u].subStruct; x_max = *tableau++;
*
* x_min = tableau->minX; if ( (x>=x_min && x<=x_max) ) {
* x_max = tableau->maxX; flag_obstacle = walkboxColor[computedVar14];
*
* if ( (x>=x_min && x<=x_max) ) */
{
flag_obstacle = walkboxType[computedVar14]; /* sa couleur */
return; return;
} }
} }
polygone = polygone->field_0; polygone = next;
} }
flag_obstacle = 0; flag_obstacle = 0;
@ -306,7 +301,7 @@ int point_proche(int16 table[][2]) {
int x1, y1, i, x, y, p; int x1, y1, i, x, y, p;
int d1 = 1000; int d1 = 1000;
ctpVar19 = ctpVar11; polyStruct0 = polyStructNorm;
if (nclick_noeud == 1) { if (nclick_noeud == 1) {
x = x_mouse; x = x_mouse;
@ -314,19 +309,19 @@ int point_proche(int16 table[][2]) {
x1 = table_ptselect[0][0]; x1 = table_ptselect[0][0];
y1 = table_ptselect[0][1]; y1 = table_ptselect[0][1];
ctpVar19 = ctpVar15; polyStruct0 = polyStructExp;
getPixel(x, y); getPixel(x, y);
if (!flag_obstacle) { if (!flag_obstacle) {
ctpVar19 = ctpVar11; polyStruct0 = polyStructNorm;
getPixel(x, y); getPixel(x, y);
if (flag_obstacle) { if (flag_obstacle) {
polydroite(x1, y1, x, y); polydroite(x1, y1, x, y);
} }
ctpVar19 = ctpVar15; polyStruct0 = polyStructExp;
} }
if (!flag_obstacle) { /* dans flag_obstacle --> couleur du point */ if (!flag_obstacle) { /* dans flag_obstacle --> couleur du point */
x1 = table_ptselect[0][0]; x1 = table_ptselect[0][0];
@ -338,7 +333,7 @@ int point_proche(int16 table[][2]) {
y_mouse = Y; y_mouse = Y;
} }
} }
ctpVar19 = ctpVar11; polyStruct0 = polyStructNorm;
p = -1; p = -1;
for (i = 0; i < ctp_routeCoordCount; i++) { for (i = 0; i < ctp_routeCoordCount; i++) {
@ -468,7 +463,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
table_ptselect[*nclick][0] = x_mouse; table_ptselect[*nclick][0] = x_mouse;
table_ptselect[*nclick][1] = y_mouse; table_ptselect[*nclick][1] = y_mouse;
(*nclick)++; (*nclick)++;
ctpVar19 = ctpVar11; polyStruct0 = polyStructNorm;
if (*nclick == 2) { // second point if (*nclick == 2) { // second point
x1 = table_ptselect[0][0]; x1 = table_ptselect[0][0];
@ -479,7 +474,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
return; return;
} }
flag_aff_chemin = 1; flag_aff_chemin = 1;
ctpVar19 = ctpVar15; polyStruct0 = polyStructExp;
// can we go there directly ? // can we go there directly ?
polydroite(x1, y1, x2, y2); polydroite(x1, y1, x2, y2);
@ -489,7 +484,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
if (!flag_obstacle) { if (!flag_obstacle) {
solution0[0][0] = x1; solution0[0][0] = x1;
solution0[0][1] = y1; solution0[0][1] = y1;
ctpVar19 = ctpVar15; polyStruct0 = polyStructExp;
poly2(x2, y2, ctp_routeCoords[select_noeud[1]][0], poly2(x2, y2, ctp_routeCoords[select_noeud[1]][0],
ctp_routeCoords[select_noeud[1]][1]); ctp_routeCoords[select_noeud[1]][1]);
@ -533,7 +528,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
solution0[++i][1] = solution0[++i][1] =
ctp_routeCoords[p1][1]; ctp_routeCoords[p1][1];
} }
ctpVar19 = ctpVar15; polyStruct0 = polyStructExp;
poly2(x2, y2, poly2(x2, y2,
ctp_routeCoords[select_noeud[1]][0], ctp_routeCoords[select_noeud[1]][0],
ctp_routeCoords[select_noeud[1]][1]); ctp_routeCoords[select_noeud[1]][1]);
@ -558,7 +553,7 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2
while (flag_obstacle && i != d) { while (flag_obstacle && i != d) {
x2 = solution0[i][0]; x2 = solution0[i][0];
y2 = solution0[i][1]; y2 = solution0[i][1];
ctpVar19 = ctpVar15; polyStruct0 = polyStructExp;
polydroite(x1, y1, x2, y2); polydroite(x1, y1, x2, y2);
i--; i--;
} }
@ -597,7 +592,7 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16
} }
} }
//if (!flagCt) if (!flagCt)
{ {
int i; int i;
int16 *ptr; int16 *ptr;
@ -637,7 +632,7 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16
} }
nclick_noeud = 0; nclick_noeud = 0;
ctpVar19 = ctpVar11; polyStruct0 = polyStructNorm;
flag_aff_chemin = 0; flag_aff_chemin = 0;
if (x == destX && y == destY) { if (x == destX && y == destY) {
@ -689,12 +684,9 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16
y_mouse = destY; y_mouse = destY;
if ((point_select = point_proche(ctp_routeCoords)) != -1) if ((point_select = point_proche(ctp_routeCoords)) != -1)
valide_noeud(select_noeud, point_select, &nclick_noeud, valide_noeud(select_noeud, point_select, &nclick_noeud, perso->solution);
perso->solution);
if ((!flag_aff_chemin) if ((!flag_aff_chemin) || ((table_ptselect[0][0] == table_ptselect[1][0]) && (table_ptselect[0][1] == table_ptselect[1][1]))) {
|| ((table_ptselect[0][0] == table_ptselect[1][0])
&& (table_ptselect[0][1] == table_ptselect[1][1]))) {
pSolution[0] = -1; pSolution[0] = -1;
pSolution[1] = -1; pSolution[1] = -1;
freePerso(num); freePerso(num);

View file

@ -98,8 +98,7 @@ int CruiseEngine::go() {
void CruiseEngine::initialize() { void CruiseEngine::initialize() {
PCFadeFlag = 0; PCFadeFlag = 0;
ptr_something = workBuffer = (uint8 *) mallocAndZero(8192);
(ctpVar19Struct *) mallocAndZero(sizeof(ctpVar19Struct) * 0x200);
/*volVar1 = 0; /*volVar1 = 0;
* fileData1 = 0; */ * fileData1 = 0; */

View file

@ -1924,16 +1924,13 @@ int oldmain(int argc, char *argv[]) {
printf("Initializing engine...\n"); printf("Initializing engine...\n");
// initBuffer(scaledScreen,640,400);
PCFadeFlag = 0; PCFadeFlag = 0;
//lowLevelInit(); //lowLevelInit();
// arg parser stuff // arg parser stuff
ptr_something = workBuffer = (uint8 *) mallocAndZero(8192);
(ctpVar19Struct *) mallocAndZero(sizeof(ctpVar19Struct) * 0x200);
/*volVar1 = 0; /*volVar1 = 0;
* fileData1 = 0; */ * fileData1 = 0; */
@ -1956,7 +1953,7 @@ int oldmain(int argc, char *argv[]) {
//freeStuff(); //freeStuff();
//freePtr(ptr_something); //freePtr(workBuffer);
return (0); return (0);
} }

View file

@ -96,7 +96,7 @@ void *mallocAndZero(int32 size);
uint8 *mainProc14(uint16 overlay, uint16 idx); uint8 *mainProc14(uint16 overlay, uint16 idx);
void printInfoBlackBox(const char *string); void printInfoBlackBox(const char *string);
void waitForPlayerInput(void); void waitForPlayerInput(void);
int loadCtp(const char * ctpName); int initCt(const char * ctpName);
void loadPakedFileToMem(int fileIdx, uint8 * buffer); void loadPakedFileToMem(int fileIdx, uint8 * buffer);
int getNumObjectsByClass(int scriptIdx, int param); int getNumObjectsByClass(int scriptIdx, int param);
void resetFileEntryRange(int param1, int param2); void resetFileEntryRange(int param1, int param2);

View file

@ -28,14 +28,14 @@
namespace Cruise { namespace Cruise {
ctpVar19Struct *ptr_something; uint8 *workBuffer;
ctpVar19Struct *polyStruct; uint8 *polyStruct;
ctpVar19Struct *ctpVar11; uint8 *adrStructPoly;
ctpVar19Struct *ctpVar13; uint8 *polyStructNorm;
ctpVar19Struct *ctpVar15; uint8 *polyStructExp;
uint8 *ctpVar17; uint8 *ctpVar17;
ctpVar19Struct *ctpVar19; uint8 *polyStruct0;
int currentWalkBoxCenterX; int currentWalkBoxCenterX;
int currentWalkBoxCenterY; int currentWalkBoxCenterY;
@ -58,7 +58,7 @@ int ctpProc2(int varX, int varY, int paramX, int paramY) {
} }
// this function process path finding coordinates // this function process path finding coordinates
void loadCtpSub2(short int coordCount, short int *ptr) { void computeDistance(short int coordCount, short int *ptr) {
// coordCount = ctp_routeCoordCount, ptr = ctpVar8 // coordCount = ctp_routeCoordCount, ptr = ctpVar8
int i; int i;
int offset = 0; int offset = 0;
@ -89,37 +89,27 @@ void loadCtpSub2(short int coordCount, short int *ptr) {
} }
} }
void getWalkBoxCenter(int boxIdx, uint16 *_walkboxTable) { void getWalkBoxCenter(int n, int16 table[][40]) {
int minX = 1000; int minX = 1000;
int minY = 1000; int minY = 1000;
int maxX = -1; int maxX = -1;
int maxY = -1; int maxY = -1;
ASSERT(boxIdx <= 15); // max number of walkboxes is 16 for(int i=0; i< table[n][0]; i++) {
ASSERT(_walkboxTable[boxIdx * 40]); // we should never have an empty walk box int x = table[n][i*2+1];
int y = table[n][i*2+2];
if (_walkboxTable[boxIdx * 40] > 0) { if (x < minX)
int numPoints = _walkboxTable[boxIdx * 40]; minX = x;
uint16 *pCurrentPtr = _walkboxTable + (boxIdx * 40) + 1;
int i; if (x > maxX)
maxX = x;
for (i = 0; i < numPoints; i++) { if (y < minY)
int X = *(pCurrentPtr++); minY = y;
int Y = *(pCurrentPtr++);;
if (X < minX) if (y > maxY)
minX = X; maxY = y;
if (X > maxX)
maxX = X;
if (Y < minY)
minY = Y;
if (Y > maxY)
maxY = Y;
}
} }
currentWalkBoxCenterX = ((maxX - minX) / 2) + minX; currentWalkBoxCenterX = ((maxX - minX) / 2) + minX;
@ -127,16 +117,15 @@ void getWalkBoxCenter(int boxIdx, uint16 *_walkboxTable) {
} }
// ax dx bx // ax dx bx
void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2, void renderCTPWalkBox(int16 *walkboxData, int hotPointX, int hotPointY, int X, int Y, int scale ) {
uint16 *walkboxData) {
int numPoints; int numPoints;
int wbSelf1; int wbSelf1;
int wbSelf2; int wbSelf2;
int i; int i;
int16 *destination; int16 *destination;
wbSelf1 = upscaleValue(X1, scale) - X2; wbSelf1 = upscaleValue(hotPointX, scale) - X;
wbSelf2 = upscaleValue(Y1, scale) - Y2; wbSelf2 = upscaleValue(hotPointY, scale) - Y;
numPoints = *(walkboxData++); numPoints = *(walkboxData++);
@ -149,8 +138,10 @@ void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2,
int scaledX = upscaleValue(pointX, scale) - wbSelf1; int scaledX = upscaleValue(pointX, scale) - wbSelf1;
int scaledY = upscaleValue(pointY, scale) - wbSelf2; int scaledY = upscaleValue(pointY, scale) - wbSelf2;
*(destination++) = scaledX >> 16; /* *(destination++) = scaledX >> 16;
*(destination++) = scaledY >> 16; *(destination++) = scaledY >> 16; */
*(destination++) = pointX;
*(destination++) = pointY;
} }
m_color = 0; m_color = 0;
@ -164,119 +155,58 @@ void renderCTPWalkBox(int X1, int Y1, int X2, int scale, int Y2,
} }
// this process the walkboxes // this process the walkboxes
void loadCtpSub1(int boxIdx, int scale, uint16 *_walkboxTable, void makeCtStruct(uint8* str, int16 table[][40], int num, int z) {
ctpVar19Struct *param4) {
int minX = 1000; int minX = 1000;
int minY = 1000;
int maxX = -1; int maxX = -1;
int maxY = -1;
ctpVar19Struct *var_1C; if(table[num][0] < 1)
ctpVar19Struct *var_12; return;
// int16 *var_18;
// int16 *si;
// int16* di;
// uint8* cx;
// int bx;
// int ax;
// int var_2;
// int var_E;
//int var_C = 1000;
//int var_A = 0;
ctpVar19SubStruct *subStruct;
ASSERT(boxIdx <= 15); getWalkBoxCenter(num, table);
if (_walkboxTable[boxIdx * 40] > 0) { // is walkbox used ?
getWalkBoxCenter(boxIdx, _walkboxTable);
currentWalkBoxCenterYBis = currentWalkBoxCenterY;
currentWalkBoxCenterXBis = currentWalkBoxCenterX; currentWalkBoxCenterXBis = currentWalkBoxCenterX;
// + 512 currentWalkBoxCenterYBis = currentWalkBoxCenterY;
renderCTPWalkBox(currentWalkBoxCenterX, currentWalkBoxCenterY,
currentWalkBoxCenterX, scale + 0x200,
currentWalkBoxCenterY, _walkboxTable + boxIdx * 40);
var_1C = param4; renderCTPWalkBox(&table[num][0], currentWalkBoxCenterX, currentWalkBoxCenterY, currentWalkBoxCenterX, currentWalkBoxCenterY, z + 0x200 );
var_12 = var_1C + 1; // next
/*
var_18 = XMIN_XMAX;
var_E = 0;
si = &XMIN_XMAX[1]; int16* a1;
if (*si>=0) int16* a2;
* {
* di = si;
* cx = var_12;
*
* do
* {
* di++;
* bx = di[-1];
* ax = di[0];
* di++;
*
* var_2 = ax;
* if (var_C < bx)
* {
* var_C = bx;
* }
*
* if (var_2 < var_A)
* {
* var_A = var_2;
* }
*
* *cx = bx;
* cx++;
* *cx = var_2;
* cx++;
* var_E ++;
* } while (di);
*
* var_12 = cx;
* } */
/*************/ a1 = a2 = (int16*)str;
{ a2 += 4+sizeof(int16*); // skip header
int i;
int numPoints;
uint16 *pCurrentPtr = _walkboxTable + boxIdx * 40;
numPoints = *(pCurrentPtr++); int16* XArray = XMIN_XMAX;
int minY = *XArray++;
for (i = 0; i < numPoints; i++) { int i=0;
int X = *(pCurrentPtr++);
int Y = *(pCurrentPtr++);
if (X < minX) while( *XArray >= 0 ) {
minX = X; int x1 = *XArray++;
int x2 = *XArray++;
if (X > maxX) if(x1<minX)
maxX = X; minX = x1;
if (Y < minY) if(x2>maxX)
minY = Y; maxX = x2;
if (Y > maxY) *a2++ = x1;
maxY = Y; *a2++ = x2;
i++;
} }
} *(int16**)a1 = a2;
/************/
var_1C->field_0 = var_12; adrStructPoly = (uint8*)a2;
ctpVar13 = var_12;
var_12->field_0 = (ctpVar19Struct *) (-1);
subStruct = &var_1C->subStruct; *(uint16**)a2 = (uint16*)-1;
subStruct->boxIdx = boxIdx; a1+=sizeof(int16*);
subStruct->type = walkboxType[boxIdx]; *a1++=num;
subStruct->minX = minX; *a1++=walkboxColor[num];
subStruct->maxX = maxX; *a1++=minX;
subStruct->minY = minY; *a1++=maxX;
subStruct->maxY = maxY; *a1++=minY;
} *a1++=minY+i+2;
} }
int getNode(int nodeResult[2], int nodeId){ int getNode(int nodeResult[2], int nodeId){
@ -289,21 +219,17 @@ int getNode(int nodeResult[2], int nodeId){
return 0; return 0;
} }
int loadCtp(const char *ctpName) { int initCt(const char *ctpName) {
int walkboxCounter; // si
uint8 *ptr;
uint8 *dataPointer; // ptr2 uint8 *dataPointer; // ptr2
char fileType[5]; // string2 char fileType[5]; // string2
short int segementSizeTable[7]; // tempTable short int segementSizeTable[7]; // tempTable
if (ctpVar1 == 0) { if ( !loadCtFromSave) {
int i; for (int i = 0; i < 10; i++) {
for (i = 0; i < 10; i++) {
persoTable[i] = NULL; persoTable[i] = NULL;
} }
} }
uint8* ptr = NULL;
if (!loadFileSub1(&ptr, ctpName, 0)) { if (!loadFileSub1(&ptr, ctpName, 0)) {
free(ptr); free(ptr);
return (-18); return (-18);
@ -320,96 +246,111 @@ int loadCtp(const char *ctpName) {
return (0); return (0);
} }
memcpy(&ctp_routeCoordCount, dataPointer, 2); // get the number of path-finding coordinates ctp_routeCoordCount = readB16(dataPointer); // get the number of nods
dataPointer += 2; dataPointer += 2;
flipShort(&ctp_routeCoordCount);
memcpy(segementSizeTable, dataPointer, 0xE); for(int i=0; i<7; i++) {
dataPointer += 0xE; // + 14 segementSizeTable[i] = readB16(dataPointer);
flipGen(segementSizeTable, 0xE); dataPointer += 2;
}
memcpy(ctp_routeCoords, dataPointer, segementSizeTable[0]); // get the path-finding coordinates // get the path-finding coordinates
dataPointer += segementSizeTable[0]; ASSERT((segementSizeTable[0]%4) == 0);
flipGen(ctp_routeCoords, segementSizeTable[0]); for(int i=0; i<segementSizeTable[0]/4; i++) {
ctp_routeCoords[i][0] = readB16(dataPointer);
dataPointer += 2;
ctp_routeCoords[i][1] = readB16(dataPointer);
dataPointer += 2;
}
memcpy(ctp_routes, dataPointer, segementSizeTable[1]); // get the path-finding line informations (indexing the routeCoords array) // get the path-finding line informations (indexing the routeCoords array)
dataPointer += segementSizeTable[1]; ASSERT((segementSizeTable[1]%20) == 0);
flipGen(ctp_routes, segementSizeTable[1]); for(int i=0; i<segementSizeTable[1]/20; i++) {
for(int j=0; j<10; j++) {
ctp_routes[i][j] = readB16(dataPointer);
dataPointer += 2;
}
}
memcpy(ctp_walkboxTable, dataPointer, segementSizeTable[2]); // get the walkbox coordinates and lines // read polygons
dataPointer += segementSizeTable[2]; ASSERT((segementSizeTable[2]%80) == 0);
flipGen(ctp_walkboxTable, segementSizeTable[2]); for(int i=0; i<segementSizeTable[2]/80; i++) {
for(int j=0; j<40; j++) {
ctp_walkboxTable[i][j] = readB16(dataPointer);
dataPointer += 2;
}
}
if (ctpVar1) { if (loadCtFromSave) {
// loading from save, ignore the initial values
dataPointer += segementSizeTable[3]; dataPointer += segementSizeTable[3];
dataPointer += segementSizeTable[4]; dataPointer += segementSizeTable[4];
} else { } else {
memcpy(walkboxType, dataPointer, segementSizeTable[3]); // get the walkbox type // get the walkbox type
dataPointer += segementSizeTable[3]; // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone
flipGen(walkboxType, segementSizeTable[3]); // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone ASSERT((segementSizeTable[3] % 2) == 0);
for(int i=0; i<segementSizeTable[3]/2; i++) {
memcpy(walkboxChange, dataPointer, segementSizeTable[4]); // change indicator, walkbox type can change, i.e. blocked by object (values are either 0x00 or 0x01) walkboxColor[i] = readB16(dataPointer);
dataPointer += segementSizeTable[4]; dataPointer += 2;
flipGen(walkboxChange, segementSizeTable[4]);
} }
memcpy(ctpVar6, dataPointer, segementSizeTable[5]); // unknown? always 2*16 bytes (used by S24.CTP, S33.CTP, S33_2.CTP, S34.CTP, S35.CTP, S36.CTP; values can be 0x00, 0x01, 0x03, 0x05) // change indicator, walkbox type can change, i.e. blocked by object (values are either 0x00 or 0x01)
dataPointer += segementSizeTable[5]; ASSERT((segementSizeTable[4] % 2) == 0);
flipGen(ctpVar6, segementSizeTable[5]); for(int i=0; i<segementSizeTable[4]/2; i++) {
walkboxState[i] = readB16(dataPointer);
dataPointer += 2;
}
}
memcpy(ctp_scale, dataPointer, segementSizeTable[6]); // scale values for the walkbox coordinates (don't know why there is a need for scaling walkboxes) //
dataPointer += segementSizeTable[6]; ASSERT((segementSizeTable[5] % 2) == 0);
flipGen(ctp_scale, segementSizeTable[6]); // ok for(int i=0; i<segementSizeTable[5]/2; i++) {
walkboxColorIndex[i] = readB16(dataPointer);
dataPointer += 2;
}
//
ASSERT((segementSizeTable[6] % 2) == 0);
for(int i=0; i<segementSizeTable[6]/2; i++) {
walkboxZoom[i] = readB16(dataPointer);
dataPointer += 2;
}
free(ptr); free(ptr);
strcpy(currentCtpName, ctpName); strcpy(currentCtpName, ctpName);
numberOfWalkboxes = segementSizeTable[6] / 2; // get the number of walkboxes numberOfWalkboxes = segementSizeTable[6] / 2; // get the number of walkboxes
loadCtpSub2(ctp_routeCoordCount, ctpVar8); // process path-finding stuff computeDistance(ctp_routeCoordCount, ctpVar8); // process path-finding stuff
polyStruct = ctpVar11 = ctpVar13 = ptr_something; polyStruct = polyStructNorm = adrStructPoly = workBuffer;
ptr = (uint8 *) polyStruct; ptr = (uint8 *) polyStruct;
walkboxCounter = numberOfWalkboxes; for(int i= numberOfWalkboxes-1; i >=0; i--) {
makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0 );
while ((--walkboxCounter) >= 0) {
loadCtpSub1(walkboxCounter, 0, ctp_walkboxTable, ctpVar13);
} }
ctpVar15 = ctpVar13 + 1; // was after the -1 thing polyStructExp = adrStructPoly += 4;
walkboxCounter = numberOfWalkboxes; for(int i= numberOfWalkboxes-1; i >=0; i--) {
makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20 );
while (--walkboxCounter) {
loadCtpSub1(walkboxCounter, ctp_scale[walkboxCounter] * 20,
ctp_walkboxTable, ctpVar13);
} }
//ctpVar17 = ctpVar13 - ptr + 4; int ctSize = (adrStructPoly - ptr) + 4; // for now, the +4 is a safe zone
adrStructPoly = polyStructNorm = polyStruct = (uint8 *) malloc(ctSize);
{ for(int i= numberOfWalkboxes-1; i >=0; i--) {
int numOfUsedEntries = ctpVar13 - (ctpVar19Struct *) ptr; makeCtStruct(adrStructPoly, ctp_walkboxTable, i, 0);
numOfUsedEntries++; // there is a -1 entry at the end... Original was only mallocing numOfUsedEntries*sizeof(ctpVar19Struct)+4, but this is a bit ugly...
ctpVar13 = ctpVar11 = polyStruct = (ctpVar19Struct *) malloc(numOfUsedEntries * sizeof(ctpVar19Struct));
} }
walkboxCounter = numberOfWalkboxes; polyStructExp = adrStructPoly += 4;
while ((--walkboxCounter) >= 0) {
loadCtpSub1(walkboxCounter, 0, ctp_walkboxTable, ctpVar13); for(int i= numberOfWalkboxes-1; i >=0; i--) {
makeCtStruct(adrStructPoly, ctp_walkboxTable, i, walkboxZoom[i] * 20);
} }
ctpVar15 = ctpVar13 + 1; polyStruct0 = polyStructNorm;
walkboxCounter = numberOfWalkboxes;
while (--walkboxCounter) {
loadCtpSub1(walkboxCounter, ctp_scale[walkboxCounter] * 20,
ctp_walkboxTable, ctpVar13);
}
ctpVar19 = ctpVar11;
return (1); return (1);
} }

View file

@ -42,16 +42,16 @@ struct ctpVar19Struct {
ctpVar19SubStruct subStruct; ctpVar19SubStruct subStruct;
}; };
extern ctpVar19Struct *ptr_something; extern uint8 *workBuffer;
extern ctpVar19Struct *polyStruct; extern uint8 *polyStruct;
extern ctpVar19Struct *ctpVar11; extern uint8 *adrStructPoly;
extern ctpVar19Struct *ctpVar13; extern uint8 *polyStructNorm;
extern ctpVar19Struct *ctpVar15; extern uint8 *polyStructExp;
extern uint8 *ctpVar17; extern uint8 *ctpVar17;
extern ctpVar19Struct *ctpVar19; extern uint8 *polyStruct0;
int loadCtp(const char * ctpName); int initCt(const char * ctpName);
int ctpProc2(int varX, int varY, int paramX, int paramY); int ctpProc2(int varX, int varY, int paramX, int paramY);
int getNode(int nodeResult[2], int nodeId); int getNode(int nodeResult[2], int nodeId);

View file

@ -400,7 +400,7 @@ void drawString(int32 x, int32 y, uint8 *string, uint8 *buffer, uint8 color,
} }
useDynamicBuffer = 1; useDynamicBuffer = 1;
} else { } else {
currentStrRenderBuffer = (uint8 *) ptr_something; currentStrRenderBuffer = (uint8 *) workBuffer;
useDynamicBuffer = 0; useDynamicBuffer = 0;
} }

View file

@ -728,7 +728,7 @@ int16 Op_Preload(void) {
} }
int16 Op_LoadCt(void) { int16 Op_LoadCt(void) {
return loadCtp((char*)popPtr()); return initCt((char*)popPtr());
} }
int16 Op_LoadSong(void) { int16 Op_LoadSong(void) {
@ -1095,46 +1095,6 @@ int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType) {
int flag_obstacle; // computedVar14Bis int flag_obstacle; // computedVar14Bis
void checkCollisionWithWalkBoxesBoundingBoxes(int x, int y) {
ctpVar19Struct *di = ctpVar19;
do {
int minX;
int maxX;
int minY;
int maxY;
ctpVar19SubStruct *subStruct;
if ((ctpVar19Struct *)-1 == di->field_0) { // ok, ugly, but it's in the original
flag_obstacle = 0;
return;
}
subStruct = &di->subStruct;
minX = subStruct->minX;
maxX = subStruct->maxX;
minY = subStruct->minY;
maxY = subStruct->maxY;
computedVar14 = subStruct->boxIdx; // Box index
if (!(walkboxChange[subStruct->boxIdx]) && (minY >= x)
&& (maxY <= x) && (minX >= y) && (maxX <= y)) {
/**************/
flag_obstacle = walkboxType[computedVar14];
/**************/
}
di = di->field_0;
} while (1);
flag_obstacle = 0;
}
// add animation // add animation
int16 Op_AddAnimation(void) { int16 Op_AddAnimation(void) {
int stepY = popVar(); int stepY = popVar();
@ -1176,7 +1136,7 @@ int16 Op_AddAnimation(void) {
zoom = -zoom; zoom = -zoom;
} }
checkCollisionWithWalkBoxesBoundingBoxes(params.X, params.Y); getPixel(params.X, params.Y);
setObjectPosition(overlay, obj, 3, newFrame + start); setObjectPosition(overlay, obj, 3, newFrame + start);
setObjectPosition(overlay, obj, 4, zoom); setObjectPosition(overlay, obj, 4, zoom);

View file

@ -228,8 +228,6 @@ static uint32 lastTick;
void flip() { void flip() {
int i; int i;
byte paletteRGBA[256 * 4]; byte paletteRGBA[256 * 4];
//uint8* outPtr = scaledScreen;
//uint8* inPtr = globalScreen;
if (palDirtyMax != -1) { if (palDirtyMax != -1) {
for (i = palDirtyMin; i <= palDirtyMax; i++) { for (i = palDirtyMin; i <= palDirtyMax; i++) {

View file

@ -1254,12 +1254,12 @@ void drawSprite(int objX1, int var_6, cellStruct *currentObjPtr, char *data1, in
#ifdef _DEBUG #ifdef _DEBUG
void drawCtp(void) { void drawCtp(void) {
int i; /* int i;
if (ctp_walkboxTable) { if (ctp_walkboxTable) {
for (i = 0; i < 15; i++) { for (i = 0; i < 15; i++) {
uint16 *dataPtr = &ctp_walkboxTable[i * 40]; uint16 *dataPtr = &ctp_walkboxTable[i * 40];
int type = walkboxType[i]; // show different types in different colors int type = walkboxColor[i]; // show different types in different colors
if (*dataPtr) { if (*dataPtr) {
int j; int j;
@ -1277,7 +1277,7 @@ void drawCtp(void) {
dataPtr[2], 0); dataPtr[2], 0);
} }
} }
} }*/
} }
#endif #endif

View file

@ -441,8 +441,8 @@ void saveCT(Common::OutSaveFile& currentSaveFile) {
if(numberOfWalkboxes) if(numberOfWalkboxes)
{ {
currentSaveFile.write(walkboxType, numberOfWalkboxes * 2); currentSaveFile.write(walkboxColor, numberOfWalkboxes * 2);
currentSaveFile.write(walkboxChange, numberOfWalkboxes * 2); currentSaveFile.write(walkboxState, numberOfWalkboxes * 2);
} }
for (unsigned long int i = 0; i < 10; i++) { for (unsigned long int i = 0; i < 10; i++) {
@ -474,8 +474,8 @@ void loadSavegameDataSub6(Common::InSaveFile& currentSaveFile) {
numberOfWalkboxes = currentSaveFile.readUint16LE(); numberOfWalkboxes = currentSaveFile.readUint16LE();
if (numberOfWalkboxes) { if (numberOfWalkboxes) {
currentSaveFile.read(walkboxType, numberOfWalkboxes * 2); currentSaveFile.read(walkboxColor, numberOfWalkboxes * 2);
currentSaveFile.read(walkboxChange, numberOfWalkboxes * 2); currentSaveFile.read(walkboxState, numberOfWalkboxes * 2);
} }
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
@ -907,9 +907,9 @@ int loadSavegameData(int saveGameIdx) {
//TODO: here, restart music //TODO: here, restart music
if (strlen(currentCtpName)) { if (strlen(currentCtpName)) {
ctpVar1 = 1; loadCtFromSave = 1;
loadCtp(currentCtpName); initCt(currentCtpName);
ctpVar1 = 0; loadCtFromSave = 0;
} }
//prepareFadeOut(); //prepareFadeOut();
//gfxModuleData.gfxFunction8(); //gfxModuleData.gfxFunction8();

View file

@ -155,20 +155,20 @@ int16 saveVar1;
uint8 saveVar2[97]; // recheck size uint8 saveVar2[97]; // recheck size
int16 numberOfWalkboxes; // saveVar3 int16 numberOfWalkboxes; // saveVar3
int16 walkboxType[15]; // saveVar4 int16 walkboxColor[15]; // saveVar4
int16 walkboxChange[15]; // saveVar5 int16 walkboxState[15]; // saveVar5
uint8 lastAni[16]; uint8 lastAni[16];
int32 loadFileVar1; int32 loadFileVar1;
int16 ctpVar1 = 0; int16 loadCtFromSave = 0;
int16 ctp_routeCoordCount; // ctpVar2 int16 ctp_routeCoordCount; // ctpVar2
int16 ctp_routeCoords[20][2]; // ctpVar3 int16 ctp_routeCoords[20][2]; // ctpVar3
int16 ctp_routes[20][10]; int16 ctp_routes[20][10];
uint16 ctp_walkboxTable[15 * 40]; // ctpVar5 int16 ctp_walkboxTable[15][40]; // ctpVar5
int8 ctpVar6[32]; int16 walkboxColorIndex[16];
int16 ctp_scale[15]; // ctpVar7 int16 walkboxZoom[15]; // ctpVar7
int16 ctpVar8[200]; int16 ctpVar8[200];
int16 ctpVar14; int16 ctpVar14;
@ -178,7 +178,6 @@ int16 speedGame;
int16 oldSpeedGame; int16 oldSpeedGame;
uint8 globalScreen[320 * 200]; uint8 globalScreen[320 * 200];
uint8 scaledScreen[640 * 400];
//OSystem *osystem; //OSystem *osystem;

View file

@ -250,14 +250,14 @@ extern int16 saveVar1;
extern uint8 saveVar2[97]; // recheck size extern uint8 saveVar2[97]; // recheck size
extern int16 numberOfWalkboxes; // saveVar3 extern int16 numberOfWalkboxes; // saveVar3
extern int16 walkboxType[15]; // saveVar4 // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone extern int16 walkboxColor[15]; // saveVar4 // Type: 0x00 - non walkable, 0x01 - walkable, 0x02 - exit zone
extern int16 walkboxChange[15]; // saveVar5 // walkbox can change its type: 0x00 - not changeable, 0x01 - changeable extern int16 walkboxState[15]; // saveVar5 // walkbox can change its type: 0x00 - not changeable, 0x01 - changeable
// Assumption: To change the type: walkboxType[i] -= walkboxChane[i] and vice versa // Assumption: To change the type: walkboxColor[i] -= walkboxChane[i] and vice versa
extern uint8 lastAni[16]; extern uint8 lastAni[16];
extern int32 loadFileVar1; extern int32 loadFileVar1;
extern int16 ctpVar1; extern int16 loadCtFromSave;
extern int16 ctp_routeCoordCount; // ctpVar2 // number of path-finding coordinates extern int16 ctp_routeCoordCount; // ctpVar2 // number of path-finding coordinates
extern int16 ctp_routeCoords[20][2]; // ctpVar3 // path-finding coordinates array extern int16 ctp_routeCoords[20][2]; // ctpVar3 // path-finding coordinates array
@ -279,9 +279,9 @@ extern int16 ctp_routes[20][10]; // path-finding line information
for the 20 * i slice the root x,y is routeCoords[i], routeCoords[i+2] for the 20 * i slice the root x,y is routeCoords[i], routeCoords[i+2]
the unused rest of the slice if filled up with 0xFF the unused rest of the slice if filled up with 0xFF
*/ */
extern uint16 ctp_walkboxTable[15 * 40]; // ctpVar5 // walkboxes coordinates and lines extern int16 ctp_walkboxTable[15][40]; // ctpVar5 // walkboxes coordinates and lines
extern int8 ctpVar6[32]; extern int16 walkboxColorIndex[16];
extern int16 ctp_scale[15]; // ctpVar7 // scaling information for walkboxes extern int16 walkboxZoom[15]; // ctpVar7 // scaling information for walkboxes
extern int16 ctpVar8[200]; extern int16 ctpVar8[200];
extern int16 ctpVar14; extern int16 ctpVar14;
@ -291,7 +291,6 @@ extern int16 speedGame;
extern int16 oldSpeedGame; extern int16 oldSpeedGame;
extern uint8 globalScreen[320 * 200]; extern uint8 globalScreen[320 * 200];
extern uint8 scaledScreen[640 * 400];
//extern OSystem *osystem; //extern OSystem *osystem;