Skip to content

Commit

Permalink
Some more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Nov 13, 2017
1 parent c6ff8ec commit 0815f03
Show file tree
Hide file tree
Showing 32 changed files with 665 additions and 719 deletions.
60 changes: 30 additions & 30 deletions CDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CDebug::CDebug(void dbgCallback(int), int quitParam)
WINDOW_CLOSE | WINDOW_MOVE | WINDOW_MINIMIZE | WINDOW_RESIZE);
global::s2->RegisterWindow(dbgWnd);
dbgWnd->addText("Debugger started", 0, 0, fontsize);
this->dbgCallback = dbgCallback;
this->dbgCallback_ = dbgCallback;
FrameCounterText = NULL;
FramesPerSecText = NULL;
msWaitText = NULL;
Expand Down Expand Up @@ -80,7 +80,7 @@ CDebug::CDebug(void dbgCallback(int), int quitParam)

CDebug::~CDebug()
{
global::s2->UnregisterCallback(dbgCallback);
global::s2->UnregisterCallback(dbgCallback_);
dbgWnd->setWaste();
}

Expand Down Expand Up @@ -109,7 +109,7 @@ void CDebug::actualizeData()
if(FrameCounterText != NULL)
dbgWnd->delText(FrameCounterText);
// write new FrameCounterText and draw it
sprintf(puffer1, "Actual Frame: %ld", global::s2->FrameCounter);
sprintf(puffer1, "Actual Frame: %lu", global::s2->FrameCounter);
FrameCounterText = dbgWnd->addText(puffer1, 0, 10, fontsize);

// Frames per Second
Expand All @@ -132,7 +132,7 @@ void CDebug::actualizeData()
if(msWaitText != NULL)
dbgWnd->delText(msWaitText);
// write new msWaitText and draw it
sprintf(puffer1, "Wait: %dms", global::s2->msWait);
sprintf(puffer1, "Wait: %ums", global::s2->msWait);
msWaitText = dbgWnd->addText(puffer1, 0, 35, fontsize);

// del MouseText before drawing new
Expand Down Expand Up @@ -232,7 +232,7 @@ void CDebug::actualizeData()
}
if(VertexText == NULL)
{
sprintf(puffer1, "Vertex: %d, %d", MapObj->VertexX, MapObj->VertexY);
sprintf(puffer1, "Vertex: %d, %d", MapObj->VertexX_, MapObj->VertexY_);
VertexText = dbgWnd->addText(puffer1, 260, 60, fontsize);
}
if(VertexDataText != NULL)
Expand All @@ -242,10 +242,10 @@ void CDebug::actualizeData()
}
if(VertexDataText == NULL)
{
sprintf(puffer1, "Vertex Data: x=%d, y=%d, z=%d i=%.2f h=%#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).x,
map->getVertex(MapObj->VertexX, MapObj->VertexY).y, map->getVertex(MapObj->VertexX, MapObj->VertexY).z,
((float)map->getVertex(MapObj->VertexX, MapObj->VertexY).i) / pow(2, 16),
map->getVertex(MapObj->VertexX, MapObj->VertexY).h);
sprintf(puffer1, "Vertex Data: x=%d, y=%d, z=%d i=%.2f h=%#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).x,
map->getVertex(MapObj->VertexX_, MapObj->VertexY_).y, map->getVertex(MapObj->VertexX_, MapObj->VertexY_).z,
((float)map->getVertex(MapObj->VertexX_, MapObj->VertexY_).i) / pow(2, 16),
map->getVertex(MapObj->VertexX_, MapObj->VertexY_).h);
VertexDataText = dbgWnd->addText(puffer1, 260, 70, fontsize);
}
if(VertexVectorText != NULL)
Expand All @@ -255,9 +255,9 @@ void CDebug::actualizeData()
}
if(VertexVectorText == NULL)
{
sprintf(puffer1, "Vertex Vector: (%.2f, %.2f, %.2f)", map->getVertex(MapObj->VertexX, MapObj->VertexY).normVector.x,
map->getVertex(MapObj->VertexX, MapObj->VertexY).normVector.y,
map->getVertex(MapObj->VertexX, MapObj->VertexY).normVector.z);
sprintf(puffer1, "Vertex Vector: (%.2f, %.2f, %.2f)", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).normVector.x,
map->getVertex(MapObj->VertexX_, MapObj->VertexY_).normVector.y,
map->getVertex(MapObj->VertexX_, MapObj->VertexY_).normVector.z);
VertexVectorText = dbgWnd->addText(puffer1, 260, 80, fontsize);
}
if(FlatVectorText != NULL)
Expand All @@ -267,19 +267,19 @@ void CDebug::actualizeData()
}
if(FlatVectorText == NULL)
{
sprintf(puffer1, "Flat Vector: (%.2f, %.2f, %.2f)", map->getVertex(MapObj->VertexX, MapObj->VertexY).flatVector.x,
map->getVertex(MapObj->VertexX, MapObj->VertexY).flatVector.y,
map->getVertex(MapObj->VertexX, MapObj->VertexY).flatVector.z);
sprintf(puffer1, "Flat Vector: (%.2f, %.2f, %.2f)", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).flatVector.x,
map->getVertex(MapObj->VertexX_, MapObj->VertexY_).flatVector.y,
map->getVertex(MapObj->VertexX_, MapObj->VertexY_).flatVector.z);
FlatVectorText = dbgWnd->addText(puffer1, 260, 90, fontsize);
}
if(rsuTextureText != NULL)
{
dbgWnd->delText(rsuTextureText);
rsuTextureText = NULL;
if(dbgWnd->delText(rsuTextureText))
rsuTextureText = NULL;
}
if(rsuTextureText == NULL)
{
sprintf(puffer1, "RSU-Texture: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).rsuTexture);
sprintf(puffer1, "RSU-Texture: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).rsuTexture);
rsuTextureText = dbgWnd->addText(puffer1, 260, 100, fontsize);
}
if(usdTextureText != NULL)
Expand All @@ -289,7 +289,7 @@ void CDebug::actualizeData()
}
if(usdTextureText == NULL)
{
sprintf(puffer1, "USD-Texture: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).usdTexture);
sprintf(puffer1, "USD-Texture: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).usdTexture);
usdTextureText = dbgWnd->addText(puffer1, 260, 110, fontsize);
}
if(roadText != NULL)
Expand All @@ -299,7 +299,7 @@ void CDebug::actualizeData()
}
if(roadText == NULL)
{
sprintf(puffer1, "road: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).road);
sprintf(puffer1, "road: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).road);
roadText = dbgWnd->addText(puffer1, 260, 120, fontsize);
}
if(objectTypeText != NULL)
Expand All @@ -309,7 +309,7 @@ void CDebug::actualizeData()
}
if(objectTypeText == NULL)
{
sprintf(puffer1, "objectType: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).objectType);
sprintf(puffer1, "objectType: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).objectType);
objectTypeText = dbgWnd->addText(puffer1, 260, 130, fontsize);
}
if(objectInfoText != NULL)
Expand All @@ -319,7 +319,7 @@ void CDebug::actualizeData()
}
if(objectInfoText == NULL)
{
sprintf(puffer1, "objectInfo: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).objectInfo);
sprintf(puffer1, "objectInfo: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).objectInfo);
objectInfoText = dbgWnd->addText(puffer1, 260, 140, fontsize);
}
if(animalText != NULL)
Expand All @@ -329,7 +329,7 @@ void CDebug::actualizeData()
}
if(animalText == NULL)
{
sprintf(puffer1, "animal: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).animal);
sprintf(puffer1, "animal: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).animal);
animalText = dbgWnd->addText(puffer1, 260, 150, fontsize);
}
if(unknown1Text != NULL)
Expand All @@ -339,7 +339,7 @@ void CDebug::actualizeData()
}
if(unknown1Text == NULL)
{
sprintf(puffer1, "unknown1: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).unknown1);
sprintf(puffer1, "unknown1: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).unknown1);
unknown1Text = dbgWnd->addText(puffer1, 260, 160, fontsize);
}
if(buildText != NULL)
Expand All @@ -349,7 +349,7 @@ void CDebug::actualizeData()
}
if(buildText == NULL)
{
sprintf(puffer1, "build: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).build);
sprintf(puffer1, "build: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).build);
buildText = dbgWnd->addText(puffer1, 260, 170, fontsize);
}
if(unknown2Text != NULL)
Expand All @@ -359,7 +359,7 @@ void CDebug::actualizeData()
}
if(unknown2Text == NULL)
{
sprintf(puffer1, "unknown2: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).unknown2);
sprintf(puffer1, "unknown2: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).unknown2);
unknown2Text = dbgWnd->addText(puffer1, 260, 180, fontsize);
}
if(unknown3Text != NULL)
Expand All @@ -369,7 +369,7 @@ void CDebug::actualizeData()
}
if(unknown3Text == NULL)
{
sprintf(puffer1, "unknown3: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).unknown3);
sprintf(puffer1, "unknown3: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).unknown3);
unknown3Text = dbgWnd->addText(puffer1, 260, 190, fontsize);
}
if(resourceText != NULL)
Expand All @@ -379,7 +379,7 @@ void CDebug::actualizeData()
}
if(resourceText == NULL)
{
sprintf(puffer1, "resource: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).resource);
sprintf(puffer1, "resource: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).resource);
resourceText = dbgWnd->addText(puffer1, 260, 200, fontsize);
}
if(shadingText != NULL)
Expand All @@ -389,7 +389,7 @@ void CDebug::actualizeData()
}
if(shadingText == NULL)
{
sprintf(puffer1, "shading: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).shading);
sprintf(puffer1, "shading: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).shading);
shadingText = dbgWnd->addText(puffer1, 260, 210, fontsize);
}
if(unknown5Text != NULL)
Expand All @@ -399,7 +399,7 @@ void CDebug::actualizeData()
}
if(unknown5Text == NULL)
{
sprintf(puffer1, "unknown5: %#04x", map->getVertex(MapObj->VertexX, MapObj->VertexY).unknown5);
sprintf(puffer1, "unknown5: %#04x", map->getVertex(MapObj->VertexX_, MapObj->VertexY_).unknown5);
unknown5Text = dbgWnd->addText(puffer1, 260, 220, fontsize);
}
if(editorModeText != NULL)
Expand Down
4 changes: 2 additions & 2 deletions CDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CDebug
{
private:
// callback fuction that is constructing the Debugger-Object
void (*dbgCallback)(int);
void (*dbgCallback_)(int);
// debugger window
CWindow* dbgWnd;
// text for FrameCounter
Expand Down Expand Up @@ -83,7 +83,7 @@ class CDebug

public:
// Constructor, Destructor
CDebug(void dbgCallback(int), int quitParam);
CDebug(void dbgCallback_(int), int quitParam);
~CDebug();
// Methods
void sendParam(int Param);
Expand Down
3 changes: 2 additions & 1 deletion CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CGame::CGame()
MenuResolutionX = 640;
MenuResolutionY = 480;
fullscreen = false;
showLoadScreen = true;

#ifdef _ADMINMODE
FrameCounter = 0;
Expand Down Expand Up @@ -103,7 +104,7 @@ bool CGame::UnregisterMenu(CMenu* Menu)
{
if(Menus[j] != NULL)
{
Menus[i - 1]->setActive();
Menus[j]->setActive();
break;
}
}
Expand Down
68 changes: 4 additions & 64 deletions CGame_Event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,8 @@ void CGame::EventHandling(SDL_Event* Event)
// data has been delivered to map, so no menu is in the foreground --> stop delivering
// break;
}
}

// deliver keyboard data to active menus
if(!delivered)
{
// deliver keyboard data to active menus
for(int i = 0; i < MAXMENUS; i++)
{
if(Menus[i] != NULL && Menus[i]->isActive() && !Menus[i]->isWaste())
Expand Down Expand Up @@ -100,26 +97,7 @@ void CGame::EventHandling(SDL_Event* Event)
TRIANGLE_WIDTH += 11;
TRIANGLE_INCREASE += 1;
bobMAP* myMap = MapObj->getMap();
int a;
int b = 0;
int heightFactor;
for(int j = 0; j < myMap->height; j++)
{
if(j % 2 == 0)
a = TRIANGLE_WIDTH / 2;
else
a = TRIANGLE_WIDTH;

for(int i = 0; i < myMap->width; i++)
{
heightFactor = myMap->getVertex(i, j).h;
myMap->getVertex(i, j).x = a;
myMap->getVertex(i, j).y = b + (-TRIANGLE_INCREASE) * (heightFactor - 0x0A);
myMap->getVertex(i, j).z = TRIANGLE_INCREASE * (heightFactor - 0x0A);
a += TRIANGLE_WIDTH;
}
b += TRIANGLE_HEIGHT;
}
myMap->updateVertexCoords();
CSurface::get_nodeVectors(myMap);
callback::PleaseWait(WINDOW_QUIT_MESSAGE);
}
Expand All @@ -131,26 +109,7 @@ void CGame::EventHandling(SDL_Event* Event)
TRIANGLE_WIDTH = 56;
TRIANGLE_INCREASE = 5;
bobMAP* myMap = MapObj->getMap();
int a;
int b = 0;
int heightFactor;
for(int j = 0; j < myMap->height; j++)
{
if(j % 2 == 0)
a = TRIANGLE_WIDTH / 2;
else
a = TRIANGLE_WIDTH;

for(int i = 0; i < myMap->width; i++)
{
heightFactor = myMap->getVertex(i, j).h;
myMap->getVertex(i, j).x = a;
myMap->getVertex(i, j).y = b + (-TRIANGLE_INCREASE) * (heightFactor - 0x0A);
myMap->getVertex(i, j).z = TRIANGLE_INCREASE * (heightFactor - 0x0A);
a += TRIANGLE_WIDTH;
}
b += TRIANGLE_HEIGHT;
}
myMap->updateVertexCoords();
CSurface::get_nodeVectors(myMap);
callback::PleaseWait(WINDOW_QUIT_MESSAGE);
}
Expand All @@ -163,26 +122,7 @@ void CGame::EventHandling(SDL_Event* Event)
TRIANGLE_WIDTH -= 11;
TRIANGLE_INCREASE -= 1;
bobMAP* myMap = MapObj->getMap();
int a;
int b = 0;
int heightFactor;
for(int j = 0; j < myMap->height; j++)
{
if(j % 2 == 0)
a = TRIANGLE_WIDTH / 2;
else
a = TRIANGLE_WIDTH;

for(int i = 0; i < myMap->width; i++)
{
heightFactor = myMap->getVertex(i, j).h;
myMap->getVertex(i, j).x = a;
myMap->getVertex(i, j).y = b + (-TRIANGLE_INCREASE) * (heightFactor - 0x0A);
myMap->getVertex(i, j).z = TRIANGLE_INCREASE * (heightFactor - 0x0A);
a += TRIANGLE_WIDTH;
}
b += TRIANGLE_HEIGHT;
}
myMap->updateVertexCoords();
CSurface::get_nodeVectors(myMap);
callback::PleaseWait(WINDOW_QUIT_MESSAGE);
}
Expand Down
8 changes: 3 additions & 5 deletions CGame_Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,9 @@ bool CGame::Init()
// std::cout << "\nShow loading screen...";
showLoadScreen = true;
// CSurface::Draw(Surf_Display, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface, 0, 0);
sge_TexturedRect(
Surf_Display, 0, 0, Surf_Display->w - 1, 0, 0, Surf_Display->h - 1, Surf_Display->w - 1, Surf_Display->h - 1,
global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface, 0, 0, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->w - 1, 0, 0,
global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->h - 1, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->w - 1,
global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->h - 1);
SDL_Surface* surfSplash = global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface;
sge_TexturedRect(Surf_Display, 0, 0, Surf_Display->w - 1, 0, 0, Surf_Display->h - 1, Surf_Display->w - 1, Surf_Display->h - 1,
surfSplash, 0, 0, surfSplash->w - 1, 0, 0, surfSplash->h - 1, surfSplash->w - 1, surfSplash->h - 1);
SDL_Flip(Surf_Display);

// continue loading pictures
Expand Down
11 changes: 5 additions & 6 deletions CGame_Render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void CGame::Render()
*/
// we are in game
if((Surf_Display->w != GameResolutionX || Surf_Display->h != GameResolutionY)
|| ((fullscreen && !(Surf_Display->flags & SDL_FULLSCREEN)) || (!fullscreen && (Surf_Display->flags & SDL_FULLSCREEN))))
|| fullscreen != ((Surf_Display->flags & SDL_FULLSCREEN) != 0))
{
SDL_FreeSurface(Surf_Display);
Surf_Display = NULL;
Expand All @@ -77,11 +77,10 @@ void CGame::Render()
if(showLoadScreen)
{
// CSurface::Draw(Surf_Display, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface, 0, 0);
sge_TexturedRect(
Surf_Display, 0, 0, Surf_Display->w - 1, 0, 0, Surf_Display->h - 1, Surf_Display->w - 1, Surf_Display->h - 1,
global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface, 0, 0, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->w - 1, 0,
0, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->h - 1, global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->w - 1,
global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface->h - 1);
SDL_Surface* surfLoadScreen = global::bmpArray[SPLASHSCREEN_LOADING_S2SCREEN].surface;
sge_TexturedRect(Surf_Display, 0, 0, Surf_Display->w - 1, 0, 0, Surf_Display->h - 1, Surf_Display->w - 1, Surf_Display->h - 1,
surfLoadScreen, 0, 0, surfLoadScreen->w - 1, 0, 0, surfLoadScreen->h - 1, surfLoadScreen->w - 1,
surfLoadScreen->h - 1);

if(CSurface::useOpenGL)
{
Expand Down
Loading

0 comments on commit 0815f03

Please sign in to comment.