From 3601170ccf7c8902f0a2f968ba21e82caa554b8a Mon Sep 17 00:00:00 2001 From: caldfir Date: Sat, 7 Sep 2013 20:49:37 -0700 Subject: [PATCH] remove terrible ancient global variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAK MEGASHOTS AGAIN ಠ_ಠ --- Config.cpp | 18 ++++----- DumpInfo.cpp | 12 +++--- GUI.cpp | 73 +++++++++++++++++++---------------- MapLoading.cpp | 49 +++++++++--------------- MapLoading.h | 17 +-------- SegmentProcessing.cpp | 18 ++++----- SegmentProcessing.h | 2 +- Tile.cpp | 8 ++-- TileTree.cpp | 2 +- TrackingModes.cpp | 18 ++++----- UserInput.cpp | 68 ++++++++++++++++----------------- WorldSegment.cpp | 89 +++++++++++++++++++++++-------------------- WorldSegment.h | 47 +++++++++-------------- common.h | 4 +- commonTypes.h | 4 +- main.cpp | 27 ++++++------- 16 files changed, 216 insertions(+), 240 deletions(-) diff --git a/Config.cpp b/Config.cpp index c80d333f..998ba474 100644 --- a/Config.cpp +++ b/Config.cpp @@ -78,24 +78,24 @@ void parseConfigLine( string line ) string result = parseStrFromLine( "WINDOWED", line ); ssConfig.Fullscreen = (result == "NO"); } - if( line.find("[SEGMENTSIZE_XY") != -1) { - int value = parseIntFromLine( "SEGMENTSIZE_XY", line ); + if( line.find("[Size_XY") != -1) { + int value = parseIntFromLine( "Size_XY", line ); if(value < 1) { - value = DEFAULT_SEGMENTSIZE; + value = DEFAULT_Size; } if(value > 100) { value = 100; } //plus 2 to allow edge readings - ssState.SegmentSize.x = value+2; - ssState.SegmentSize.y = value+2; + ssState.Size.x = value+2; + ssState.Size.y = value+2; } - if( line.find("[SEGMENTSIZE_Z") != -1) { - int value = parseIntFromLine( "SEGMENTSIZE_Z", line ); + if( line.find("[Size_Z") != -1) { + int value = parseIntFromLine( "Size_Z", line ); if(value < 1) { - value = DEFAULT_SEGMENTSIZE_Z; + value = DEFAULT_Size_Z; } - ssState.SegmentSize.z = value; + ssState.Size.z = value; } if( line.find("[ALLCREATURES") != -1) { diff --git a/DumpInfo.cpp b/DumpInfo.cpp index 2184f432..db1fe37f 100644 --- a/DumpInfo.cpp +++ b/DumpInfo.cpp @@ -34,9 +34,9 @@ void dumpSegment() al_lock_mutex(ssConfig.readMutex); //back up all the relevant values - Crd3D tempSize = ssState.SegmentSize; - int tempViewx = DisplayedSegment.x; - int tempViewy = DisplayedSegment.y; + Crd3D tempSize = ssState.Size; + int tempViewx = Position.x; + int tempViewy = Position.y; bool tempFollow = ssConfig.follow_DFscreen; int tempLift = ssConfig.lift_segment_offscreen_y; int currentFlags = al_get_new_bitmap_flags(); @@ -95,9 +95,9 @@ void dumpSegment() al_set_new_bitmap_flags(tempFlags); //restore everything that we changed. - ssState.SegmentSize = tempSize; - DisplayedSegment.x = tempViewx; - DisplayedSegment.y = tempViewy; + ssState.Size = tempSize; + Position.x = tempViewx; + Position.y = tempViewy; ssConfig.follow_DFscreen = tempFollow; ssConfig.lift_segment_offscreen_y = tempLift; diff --git a/GUI.cpp b/GUI.cpp index 5347d180..b4972904 100644 --- a/GUI.cpp +++ b/GUI.cpp @@ -196,7 +196,7 @@ void ScreenToPoint(int x,int y,int &x1, int &y1, int &z1, int segSizeX, int segS void ScreenToPoint(int x,int y,int &x1, int &y1, int &z1) { if(ssConfig.track_screen_center){ - ScreenToPoint(x, y, x1, y1, z1, ssState.SegmentSize.x, ssState.SegmentSize.y, ssState.ScreenW, ssState.ScreenH); + ScreenToPoint(x, y, x1, y1, z1, ssState.Size.x, ssState.Size.y, ssState.ScreenW, ssState.ScreenH); } else { ScreenToPoint(x, y, x1, y1, z1, 0, 0, 0, 0); } @@ -229,7 +229,7 @@ void pointToScreen(int *inx, int *iny, int inz, int segSizeX, int segSizeY, int void pointToScreen(int *inx, int *iny, int inz) { if(ssConfig.track_screen_center){ - pointToScreen(inx, iny, inz, ssState.SegmentSize.x, ssState.SegmentSize.y, ssState.ScreenW, ssState.ScreenH); + pointToScreen(inx, iny, inz, ssState.Size.x, ssState.Size.y, ssState.ScreenW, ssState.ScreenH); } else { pointToScreen(inx, iny, inz, 0, 0, 0, 0); } @@ -312,6 +312,13 @@ void draw_ustr_border(const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, fl al_draw_ustr(font, color, x, y, flags, ustr); } +void correctTileForDisplayedOffset(int32_t& x, int32_t& y, int32_t& z) +{ + x -= ssState.Position.x; + y -= ssState.Position.y; //Position.y; + z -= ssState.Position.z - 1; // + viewedSegment->sizez - 2; // loading one above the top of the displayed segment for tile rules +} + /** * Corrects the coordinate (x,y) for rotation in a region of size (szx, szy). */ @@ -350,11 +357,11 @@ Crd2D LocalTileToScreen(int32_t x, int32_t y, int32_t z) void DrawCurrentLevelOutline(bool backPart) { - int x = ssState.DisplayedSegment.x+1; - int y = ssState.DisplayedSegment.y+1; - int z = ssState.DisplayedSegment.z; - int sizex = ssState.SegmentSize.x-2; - int sizey = ssState.SegmentSize.y-2; + int x = ssState.Position.x+1; + int y = ssState.Position.y+1; + int z = ssState.Position.z; + int sizex = ssState.Size.x-2; + int sizey = ssState.Size.y-2; if(ssConfig.hide_outer_tiles) { x++; @@ -424,7 +431,7 @@ void drawDebugCursorAndInfo(WorldSegment * segment) 0); //get tile info - Tile* b = segment->getTileLocal( debugCursor.x, debugCursor.y, debugCursor.z+segment->size.z-2); + Tile* b = segment->getTileLocal( debugCursor.x, debugCursor.y, debugCursor.z+segment->segState.Size.z-2); int i = 10; draw_textf_border(font, al_map_rgb(255,255,255), 2, (i++*al_get_font_line_height(font)), 0, "Tile 0x%x", b); @@ -870,10 +877,10 @@ void DrawMinimap(WorldSegment * segment) int mapheight = (int)(segment->segState.RegionDim.y * oneTileInPixels); al_draw_rectangle(posx, posy, posx+size, posy+mapheight, al_map_rgb(0,0,0),0); //current segment outline - int x = (size * (segment->pos.x+1)) / segment->segState.RegionDim.x; - int y = (mapheight * (segment->pos.y+1)) / segment->segState.RegionDim.y; - MiniMapSegmentWidth = (segment->size.x-2) * oneTileInPixels; - MiniMapSegmentHeight = (segment->size.y-2) * oneTileInPixels; + int x = (size * (segment->segState.Position.x+1)) / segment->segState.RegionDim.x; + int y = (mapheight * (segment->segState.Position.y+1)) / segment->segState.RegionDim.y; + MiniMapSegmentWidth = (segment->segState.Size.x-2) * oneTileInPixels; + MiniMapSegmentHeight = (segment->segState.Size.y-2) * oneTileInPixels; al_draw_rectangle(posx+x, posy+y, posx+x+MiniMapSegmentWidth, posy+y+MiniMapSegmentHeight,al_map_rgb(0,0,0),0); MiniMapTopLeftX = posx; MiniMapTopLeftY = posy; @@ -1005,7 +1012,7 @@ void paintboard() al_hold_bitmap_drawing(false); } else if (ssConfig.show_osd) { al_hold_bitmap_drawing(true); - draw_textf_border(font, al_map_rgb(255,255,255), 10,al_get_font_line_height(font), 0, "%i,%i,%i, r%i, z%i", ssState.DisplayedSegment.x,ssState.DisplayedSegment.y,ssState.DisplayedSegment.z, ssState.DisplayedRotation, ssConfig.zoom); + draw_textf_border(font, al_map_rgb(255,255,255), 10,al_get_font_line_height(font), 0, "%i,%i,%i, r%i, z%i", ssState.Position.x,ssState.Position.y,ssState.Position.z, ssState.DisplayedRotation, ssConfig.zoom); if(ssConfig.debug_mode) { draw_textf_border(font, al_map_rgb(255,255,255), 10, 3*al_get_font_line_height(font), 0, "Map Read Time: %.2fms", ssTimers.read_time); @@ -1381,7 +1388,7 @@ void saveMegashot(bool tall) if(tall) { ssState.ScreenH = ( ((ssState.RegionDim.x + ssState.RegionDim.y) * TILETOPHEIGHT / 2) + (ssState.RegionDim.z * TILEHEIGHT) )*ssConfig.scale; } else { - ssState.ScreenH = ( ((ssState.RegionDim.x + ssState.RegionDim.y) * TILETOPHEIGHT / 2) + ((ssState.SegmentSize.z - 1) * TILEHEIGHT) )*ssConfig.scale; + ssState.ScreenH = ( ((ssState.RegionDim.x + ssState.RegionDim.y) * TILETOPHEIGHT / 2) + ((ssState.Size.z - 1) * TILEHEIGHT) )*ssConfig.scale; } bigFile = al_create_bitmap(ssState.ScreenW, ssState.ScreenH); @@ -1418,45 +1425,45 @@ void saveMegashot(bool tall) switch(ssState.DisplayedRotation){ case 0: case 2: - incrx = parms.sizex-2; - incry = parms.sizey-2; + incrx = ssState.Size.x-2; + incry = ssState.Size.y-2; numx = (int)(ssState.RegionDim.x+3); numy = (int)(ssState.RegionDim.y+3); break; case 1: case 3: - incrx = parms.sizey-2; - incry = parms.sizex-2; + incrx = ssState.Size.y-2; + incry = ssState.Size.x-2; numx = (int)(ssState.RegionDim.y+3); numy = (int)(ssState.RegionDim.x+3); break; } numx = numx/incrx + (numx%incrx==0 ? 0 : 1); numy = numy/incry + (numx%incry==0 ? 0 : 1); - numz = tall ? ((ssState.RegionDim.z/(parms.sizez-1)) + 1) : 1; + numz = tall ? ((ssState.RegionDim.z/(ssState.Size.z-1)) + 1) : 1; if(ssState.DisplayedRotation == 1 || ssState.DisplayedRotation == 2) { starty = (int)ssState.RegionDim.y + 2 - incry; - ssState.DisplayedSegment.y = (int)ssState.RegionDim.y - incry - 1; + ssState.Position.y = (int)ssState.RegionDim.y - incry - 1; incry = -incry; } else { - ssState.DisplayedSegment.y = -1; + ssState.Position.y = -1; } if(ssState.DisplayedRotation == 3 || ssState.DisplayedRotation == 2) { startx = (int)ssState.RegionDim.x + 2 - incrx; - ssState.DisplayedSegment.x = (int)ssState.RegionDim.x - incrx - 1; + ssState.Position.x = (int)ssState.RegionDim.x - incrx - 1; incrx = -incrx; } else { - ssState.DisplayedSegment.x = -1; + ssState.Position.x = -1; } if(tall) { - ssState.DisplayedSegment.z = ssState.RegionDim.z; + ssState.Position.z = ssState.RegionDim.z; } - parms.x = startx; - parms.y = starty; - parms.z = tall ? 0 : parms.z; + ssState.Position.x = startx; + ssState.Position.y = starty; + ssState.Position.z = tall ? 0 : ssState.Position.z; //now actually loop through and draw the subsegments for(int k=0; kDrawAllTiles(); map_segment.unlockDraw(); - parms.x += incrx; + ssState.Position.x += incrx; } - parms.x = startx; - parms.y += incry; + ssState.Position.x = startx; + ssState.Position.y += incry; } - parms.x=startx; - parms.y=starty; - parms.z += parms.sizez - 1; + ssState.Position.x=startx; + ssState.Position.y=starty; + ssState.Position.z += ssState.Size.z - 1; } diff --git a/MapLoading.cpp b/MapLoading.cpp index 499d4c31..cc10d760 100644 --- a/MapLoading.cpp +++ b/MapLoading.cpp @@ -19,7 +19,6 @@ bool connected = 0; bool threadrunnng = 0; -segParams parms; //==============================Map Read ==============================// /* @@ -483,7 +482,7 @@ void readBlockToSegment(DFHack::Core& DF, WorldSegment& segment, } } -void readMapSegment(WorldSegment* segment, int x, int y, int z, int sizex, int sizey, int sizez) +void readMapSegment(WorldSegment* segment, GameState inState) { uint32_t index; DFHack::Core & DF = Core::getInstance(); @@ -501,7 +500,7 @@ void readMapSegment(WorldSegment* segment, int x, int y, int z, int sizex, int s } if(ssConfig.skipMaps || !Maps::IsValid()) { - segment->Reset(x,y,z + 1,sizex,sizey,sizez + 1,true); + segment->Reset(inState,true); return; } @@ -522,7 +521,7 @@ void readMapSegment(WorldSegment* segment, int x, int y, int z, int sizex, int s Gui::getCursorCoords(ssState.dfCursor.x, ssState.dfCursor.y, ssState.dfCursor.z); //setup new world segment - segment->Reset(x,y,z,sizex,sizey,sizez,false); + segment->Reset(inState,false); //read world wide buildings vector allBuildings; @@ -553,13 +552,13 @@ void readMapSegment(WorldSegment* segment, int x, int y, int z, int sizex, int s } if(segment->segState.DisplayedRotation % 2) { - int temp = sizex; - sizex = sizey; - sizey = temp; + int temp = inState.Size.x; + inState.Size.x = inState.Size.y; + inState.Size.y = temp; } //figure out what blocks to read - int32_t firstTileToReadX = x; + int32_t firstTileToReadX = inState.Position.x; if( firstTileToReadX < 0 ) { firstTileToReadX = 0; } @@ -571,22 +570,22 @@ void readMapSegment(WorldSegment* segment, int x, int y, int z, int sizex, int s LogError("Can't get region geology.\n"); } - while(firstTileToReadX < x + sizex) { + while(firstTileToReadX < inState.Position.x + inState.Size.x) { int blockx = firstTileToReadX / BLOCKEDGESIZE; int32_t lastTileInBlockX = (blockx+1) * BLOCKEDGESIZE - 1; - int32_t lastTileToReadX = min(lastTileInBlockX, x+sizex-1); + int32_t lastTileToReadX = min(lastTileInBlockX, inState.Position.x + inState.Size.x-1); - int32_t firstTileToReadY = y; + int32_t firstTileToReadY = inState.Position.y; if( firstTileToReadY < 0 ) { firstTileToReadY = 0; } - while(firstTileToReadY < y + sizey) { + while(firstTileToReadY < inState.Position.y + inState.Size.y) { int blocky = firstTileToReadY / BLOCKEDGESIZE; int32_t lastTileInBlockY = (blocky+1) * BLOCKEDGESIZE - 1; - int32_t lastTileToReadY = min(lastTileInBlockY, y+sizey-1); + int32_t lastTileToReadY = min(lastTileInBlockY, inState.Position.y + inState.Size.y-1); - for(int lz=z-sizez; lz <= z; lz++) { + for(int lz=inState.Position.z - inState.Size.z; lz <= inState.Position.z; lz++) { //load the tiles from this block to the map segment readBlockToSegment(DF, *segment, blockx, blocky, lz, firstTileToReadX, firstTileToReadY, @@ -664,7 +663,7 @@ void read_segment( void *arg) } } segment = map_segment.getRead(); - readMapSegment(segment, parms.x, parms.y, parms.z,parms.sizex, parms.sizey, parms.sizez); + readMapSegment(segment, ssState); ssConfig.threadstarted = 0; } @@ -672,7 +671,7 @@ void read_segment( void *arg) beautifySegment(segment); //putting these here to increase responsiveness of the UI and to make megashots work - segment->segState.DisplayedSegment = ssState.DisplayedSegment; + segment->segState.Position = ssState.Position; segment->segState.dfCursor = ssState.dfCursor; segment->AssembleAllTiles(); @@ -695,24 +694,17 @@ static void * threadedSegment(ALLEGRO_THREAD *read_thread, void *arg) return 0; } -void reloadDisplayedSegment() +void reloadPosition() { //create handle to dfHack API static bool firstLoad = 1; if (timeToReloadConfig) { - parms.thread_connect = 0; contentLoader->Load(); timeToReloadConfig = false; } - if (firstLoad || ssConfig.track_mode != GameConfiguration::TRACKING_NONE) { - ssState.DisplayedSegment.x = parms.x; - ssState.DisplayedSegment.y = parms.y; - ssState.DisplayedSegment.z = parms.z; - } - - int segmentHeight = ssConfig.single_layer_view ? 2 : ssState.SegmentSize.z; + int segmentHeight = ssConfig.single_layer_view ? 2 : ssState.Size.z; //load segment if(ssConfig.threading_enable) { if(!ssConfig.threadmade) { @@ -721,13 +713,6 @@ void reloadDisplayedSegment() } } - parms.x = ssState.DisplayedSegment.x; - parms.y = ssState.DisplayedSegment.y; - parms.z = ssState.DisplayedSegment.z; - parms.sizex = ssState.SegmentSize.x; - parms.sizey = ssState.SegmentSize.y; - parms.sizez = segmentHeight; - if(ssConfig.threading_enable) { al_start_thread(ssConfig.readThread); } else { diff --git a/MapLoading.h b/MapLoading.h index 443646b3..d9b22204 100644 --- a/MapLoading.h +++ b/MapLoading.h @@ -8,7 +8,7 @@ #define RESUME_DF ; #endif -void reloadDisplayedSegment(); +void reloadPosition(); void DisconnectFromDF(); bool IsConnectedToDF(); @@ -18,17 +18,4 @@ void read_segment( void *arg); extern const VersionInfo *dfMemoryInfo; struct SS_Item; -SS_Item ConvertItem(df::item * found_item, WorldSegment& segment); - -struct segParams { - int x; - int y; - int z; - int sizex; - int sizey; - int sizez; - bool thread_connect; - bool is_connected; -}; - -extern segParams parms; \ No newline at end of file +SS_Item ConvertItem(df::item * found_item, WorldSegment& segment); \ No newline at end of file diff --git a/SegmentProcessing.cpp b/SegmentProcessing.cpp index 0687baf4..50d8fa6c 100644 --- a/SegmentProcessing.cpp +++ b/SegmentProcessing.cpp @@ -148,38 +148,38 @@ bool checkFloorBorderRequirement(WorldSegment* segment, int x, int y, int z, dir bool isTileOnVisibleEdgeOfSegment(WorldSegment* segment, Tile* b) { - if(b->z == segment->pos.z + segment->size.z - 2) { + if(b->z == segment->segState.Position.z + segment->segState.Size.z - 2) { return true; } if (ssState.DisplayedRotation == 0 && ( - b->x == segment->pos.x + segment->size.x - 2 - || b->y == segment->pos.y + segment->size.y - 2 + b->x == segment->segState.Position.x + segment->segState.Size.x - 2 + || b->y == segment->segState.Position.y + segment->segState.Size.y - 2 || b->x == segment->segState.RegionDim.x - 1 || b->y == segment->segState.RegionDim.y - 1 )) { return true; } else if (ssState.DisplayedRotation == 1 && ( - b->x == segment->pos.x + segment->size.y - 2 - || b->y == segment->pos.y + 1 + b->x == segment->segState.Position.x + segment->segState.Size.y - 2 + || b->y == segment->segState.Position.y + 1 || b->x == segment->segState.RegionDim.x - 1 || b->y == 0 )) { return true; } else if (ssState.DisplayedRotation == 2 && ( - b->x == segment->pos.x + 1 - || b->y == segment->pos.y + 1 + b->x == segment->segState.Position.x + 1 + || b->y == segment->segState.Position.y + 1 || b->x == 0 || b->y == 0 )) { return true; } else if (ssState.DisplayedRotation == 3 && ( - b->x == segment->pos.x + 1 - || b->y == segment->pos.y + segment->size.x - 2 + b->x == segment->segState.Position.x + 1 + || b->y == segment->segState.Position.y + segment->segState.Size.x - 2 || b->x == 0 || b->y == segment->segState.RegionDim.y - 1 )) { diff --git a/SegmentProcessing.h b/SegmentProcessing.h index 829ddfe2..6928891d 100644 --- a/SegmentProcessing.h +++ b/SegmentProcessing.h @@ -5,5 +5,5 @@ void beautifySegment(WorldSegment * segment); inline bool isTileOnTopOfSegment(WorldSegment* segment, Tile* b) { - return b->z == segment->pos.z + segment->size.z - 2; + return b->z == segment->segState.Position.z + segment->segState.Size.z - 2; } diff --git a/Tile.cpp b/Tile.cpp index 6767f41a..7d1af63c 100644 --- a/Tile.cpp +++ b/Tile.cpp @@ -295,7 +295,7 @@ void Tile::AssembleTile() if (spriteobject->get_sheetindex() != INVALID_INDEX) { spriteobject->set_size(SPRITEWIDTH, SPRITEHEIGHT); spriteobject->set_plate_layout(RAMPBOTTOMPLATE); - spriteobject->assemble_world_offset(x, y, z, 0, this, (chopThisTile && this->z == ownerSegment->pos.z + ownerSegment->size.z -2)); + spriteobject->assemble_world_offset(x, y, z, 0, this, (chopThisTile && this->z == ownerSegment->segState.Position.z + ownerSegment->segState.Size.z -2)); } spriteobject->set_plate_layout(TILEPLATE); } @@ -413,7 +413,7 @@ void Tile::AssembleTile() if (spriteobject->get_sheetindex() == INVALID_INDEX ) { //skip } else { - spriteobject->assemble_world(x, y, z, this, (chopThisTile && this->z == ownerSegment->pos.z + ownerSegment->size.z -2)); + spriteobject->assemble_world(x, y, z, this, (chopThisTile && this->z == ownerSegment->segState.Position.z + ownerSegment->segState.Size.z -2)); } } @@ -458,9 +458,9 @@ void Tile::AssembleTile() //if(waterlevel == 7) waterlevel--; uint32_t waterlevel = designation.bits.flow_size + (deepwater ? 1 : 0); if(designation.bits.liquid_type == 0) { - contentLoader->water[waterlevel-1].sprite.assemble_world(x, y, z, this, (chopThisTile && this->z == ownerSegment->pos.z + ownerSegment->size.z -2)); + contentLoader->water[waterlevel-1].sprite.assemble_world(x, y, z, this, (chopThisTile && this->z == ownerSegment->segState.Position.z + ownerSegment->segState.Size.z -2)); } else { - contentLoader->lava[waterlevel-1].sprite.assemble_world(x, y, z, this, (chopThisTile && this->z == ownerSegment->pos.z + ownerSegment->size.z -2)); + contentLoader->lava[waterlevel-1].sprite.assemble_world(x, y, z, this, (chopThisTile && this->z == ownerSegment->segState.Position.z + ownerSegment->segState.Size.z -2)); } } diff --git a/TileTree.cpp b/TileTree.cpp index d3a929aa..5e2a3a25 100644 --- a/TileTree.cpp +++ b/TileTree.cpp @@ -270,7 +270,7 @@ void c_tile_tree::insert_sprites(WorldSegment *w, int x, int y, int z, Tile * pa b->tileShapeBasic()==tiletype_shape_basic::Floor || b->tileShapeBasic()==tiletype_shape_basic::Wall || b->tileShapeBasic()==tiletype_shape_basic::Stair)) || - ((z + i + 1) > w->pos.z + w->size.z) + ((z + i + 1) > w->segState.Position.z + w->segState.Size.z) ) { break; } diff --git a/TrackingModes.cpp b/TrackingModes.cpp index 6e829afa..6e2e49bf 100644 --- a/TrackingModes.cpp +++ b/TrackingModes.cpp @@ -57,9 +57,9 @@ void followCurrentDFWindow() newviewx = newviewx + (viewsizex / 2) - mapx / 2; newviewy = newviewy + (viewsizey / 2) - mapy / 2; - parms.x = float (newviewx) * scalex - (ssState.SegmentSize.x / 2) + ssConfig.viewXoffset + mapx / 2; - parms.y = float (newviewy) * scaley - (ssState.SegmentSize.y / 2) + ssConfig.viewYoffset + mapy / 2; - parms.z = newviewz + ssConfig.viewZoffset + 1; + ssState.Position.x = float (newviewx) * scalex - (ssState.Size.x / 2) + ssConfig.viewXoffset + mapx / 2; + ssState.Position.y = float (newviewy) * scaley - (ssState.Size.y / 2) + ssConfig.viewYoffset + mapy / 2; + ssState.Position.z = newviewz + ssConfig.viewZoffset + 1; } void followCurrentDFCenter() @@ -71,18 +71,18 @@ void followCurrentDFCenter() int32_t newviewz; actualWindowSize(viewsizex,viewsizey); Gui::getViewCoords(newviewx,newviewy,newviewz); - parms.x = newviewx + (viewsizex/2) - (ssState.SegmentSize.x / 2) + ssConfig.viewXoffset; - parms.y = newviewy + (viewsizey/2) - (ssState.SegmentSize.y / 2) + ssConfig.viewYoffset; - parms.z = newviewz + ssConfig.viewZoffset + 1; + ssState.Position.x = newviewx + (viewsizex/2) - (ssState.Size.x / 2) + ssConfig.viewXoffset; + ssState.Position.y = newviewy + (viewsizey/2) - (ssState.Size.y / 2) + ssConfig.viewYoffset; + ssState.Position.z = newviewz + ssConfig.viewZoffset + 1; } //eventually, this should be a sort of "smart-follow" which switches modes intelligently void followCurrentDFFocus() { if(ssState.dfCursor.x != -30000) { - parms.x = ssState.dfCursor.x - (ssState.SegmentSize.x / 2) + ssConfig.viewXoffset; - parms.y = ssState.dfCursor.y - (ssState.SegmentSize.y / 2) + ssConfig.viewYoffset; - parms.z = ssState.dfCursor.z + ssConfig.viewZoffset + 1; + ssState.Position.x = ssState.dfCursor.x - (ssState.Size.x / 2) + ssConfig.viewXoffset; + ssState.Position.y = ssState.dfCursor.y - (ssState.Size.y / 2) + ssConfig.viewYoffset; + ssState.Position.z = ssState.dfCursor.z + ssConfig.viewZoffset + 1; } else { followCurrentDFCenter(); } diff --git a/UserInput.cpp b/UserInput.cpp index 6c5f7e5a..228b43b7 100644 --- a/UserInput.cpp +++ b/UserInput.cpp @@ -97,19 +97,19 @@ void moveViewRelativeToRotation( int stepx, int stepy ) } //if we're following the DF screen, we DO NOT bound the view, since we have a simple way to get back else { - changeRelativeToRotation(ssState.DisplayedSegment.x, ssState.DisplayedSegment.y, stepx, stepy ); + changeRelativeToRotation(ssState.Position.x, ssState.Position.y, stepx, stepy ); //bound view to world - if((int)ssState.DisplayedSegment.x > (int)ssState.RegionDim.x -(int)ssState.SegmentSize.x/2) { - ssState.DisplayedSegment.x = ssState.RegionDim.x -ssState.SegmentSize.x/2; + if((int)ssState.Position.x > (int)ssState.RegionDim.x -(int)ssState.Size.x/2) { + ssState.Position.x = ssState.RegionDim.x -ssState.Size.x/2; } - if((int)ssState.DisplayedSegment.y > (int)ssState.RegionDim.y -(int)ssState.SegmentSize.y/2) { - ssState.DisplayedSegment.y = ssState.RegionDim.y -ssState.SegmentSize.y/2; + if((int)ssState.Position.y > (int)ssState.RegionDim.y -(int)ssState.Size.y/2) { + ssState.Position.y = ssState.RegionDim.y -ssState.Size.y/2; } - if((int)ssState.DisplayedSegment.x < -(int)ssState.SegmentSize.x/2) { - ssState.DisplayedSegment.x = -ssState.SegmentSize.x/2; + if((int)ssState.Position.x < -(int)ssState.Size.x/2) { + ssState.Position.x = -ssState.Size.x/2; } - if((int)ssState.DisplayedSegment.y < -(int)ssState.SegmentSize.y/2) { - ssState.DisplayedSegment.y = -ssState.SegmentSize.y/2; + if((int)ssState.Position.y < -(int)ssState.Size.y/2) { + ssState.Position.y = -ssState.Size.y/2; } } } @@ -139,12 +139,12 @@ void doMouse() y = mouse.y; int tilex,tiley,tilez; ScreenToPoint(x,y,tilex,tiley,tilez); - int diffx = tilex - ssState.SegmentSize.x/2; - int diffy = tiley - ssState.SegmentSize.y/2; + int diffx = tilex - ssState.Size.x/2; + int diffy = tiley - ssState.Size.y/2; /*we use changeRelativeToRotation directly, and not through moveViewRelativeToRotation because we don't want to move the offset with the mouse. It just feels weird. */ // changing to +1,+1 which moves the clicked point to one of the 4 surrounding the center of rotation - changeRelativeToRotation(ssState.DisplayedSegment.x, ssState.DisplayedSegment.y, diffx+1, diffy+1 ); + changeRelativeToRotation(ssState.Position.x, ssState.Position.y, diffx+1, diffy+1 ); //moveViewRelativeToRotation(diffx+1, diffy+1); timeToReloadSegment = true; //rest(50); @@ -155,13 +155,13 @@ void doMouse() x = mouse.x;//pos >> 16; y = mouse.y; //pos & 0x0000ffff; if(x >= MiniMapTopLeftX && x <= MiniMapBottomRightX && y >= MiniMapTopLeftY && y <= MiniMapBottomRightY) { // in minimap - ssState.DisplayedSegment.x = (x-MiniMapTopLeftX-MiniMapSegmentWidth/2)/oneTileInPixels; - ssState.DisplayedSegment.y = (y-MiniMapTopLeftY-MiniMapSegmentHeight/2)/oneTileInPixels; + ssState.Position.x = (x-MiniMapTopLeftX-MiniMapSegmentWidth/2)/oneTileInPixels; + ssState.Position.y = (y-MiniMapTopLeftY-MiniMapSegmentHeight/2)/oneTileInPixels; } else { int tilex,tiley,tilez; ScreenToPoint(x,y,tilex,tiley,tilez); - int diffx = tilex - ssState.SegmentSize.x/2; - int diffy = tiley - ssState.SegmentSize.y/2; + int diffx = tilex - ssState.Size.x/2; + int diffy = tiley - ssState.Size.y/2; debugCursor.x = tilex; debugCursor.y = tiley; } @@ -252,17 +252,17 @@ void action_resetscreen(uint32_t keymod) ssConfig.viewYoffset = 0; ssConfig.viewZoffset = 0; } else { - ssState.DisplayedSegment.x = (ssState.RegionDim.x -ssState.SegmentSize.x)/2; - ssState.DisplayedSegment.y = (ssState.RegionDim.y -ssState.SegmentSize.y)/2; + ssState.Position.x = (ssState.RegionDim.x -ssState.Size.x)/2; + ssState.Position.y = (ssState.RegionDim.y -ssState.Size.y)/2; } } void action_decrsegmentX(uint32_t keymod) { char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); - ssState.SegmentSize.x -= stepsize; - if(ssState.SegmentSize.x <= 0) { - ssState.SegmentSize.x = 1; + ssState.Size.x -= stepsize; + if(ssState.Size.x <= 0) { + ssState.Size.x = 1; } timeToReloadSegment = true; } @@ -270,7 +270,7 @@ void action_decrsegmentX(uint32_t keymod) void action_incrsegmentX(uint32_t keymod) { char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); - ssState.SegmentSize.x += stepsize; + ssState.Size.x += stepsize; //add a limit? timeToReloadSegment = true; } @@ -278,9 +278,9 @@ void action_incrsegmentX(uint32_t keymod) void action_decrsegmentY(uint32_t keymod) { char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); - ssState.SegmentSize.y -= stepsize; - if(ssState.SegmentSize.y <= 0) { - ssState.SegmentSize.y = 1; + ssState.Size.y -= stepsize; + if(ssState.Size.y <= 0) { + ssState.Size.y = 1; } timeToReloadSegment = true; } @@ -288,7 +288,7 @@ void action_decrsegmentY(uint32_t keymod) void action_incrsegmentY(uint32_t keymod) { char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); - ssState.SegmentSize.y += stepsize; + ssState.Size.y += stepsize; //add a limit? timeToReloadSegment = true; } @@ -296,9 +296,9 @@ void action_incrsegmentY(uint32_t keymod) void action_decrsegmentZ(uint32_t keymod) { char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); - ssState.SegmentSize.z -= stepsize; - if(ssState.SegmentSize.z <= 0) { - ssState.SegmentSize.z = 1; + ssState.Size.z -= stepsize; + if(ssState.Size.z <= 0) { + ssState.Size.z = 1; } timeToReloadSegment = true; } @@ -306,7 +306,7 @@ void action_decrsegmentZ(uint32_t keymod) void action_incrsegmentZ(uint32_t keymod) { char stepsize = ((keymod&ALLEGRO_KEYMOD_SHIFT) ? MAPNAVIGATIONSTEPBIG : MAPNAVIGATIONSTEP); - ssState.SegmentSize.z += stepsize; + ssState.Size.z += stepsize; //add a limit? timeToReloadSegment = true; } @@ -469,10 +469,10 @@ void action_decrZ(uint32_t keymod) if (ssConfig.track_mode != GameConfiguration::TRACKING_NONE) { ssConfig.viewZoffset -= stepsize; } else { - ssState.DisplayedSegment.z -= stepsize; + ssState.Position.z -= stepsize; } - if(ssState.DisplayedSegment.z<1) { - ssState.DisplayedSegment.z = 1; + if(ssState.Position.z<1) { + ssState.Position.z = 1; } timeToReloadSegment = true; } @@ -490,7 +490,7 @@ void action_incrZ(uint32_t keymod) if (ssConfig.track_mode != GameConfiguration::TRACKING_NONE) { ssConfig.viewZoffset += stepsize; } else { - ssState.DisplayedSegment.z += stepsize; + ssState.Position.z += stepsize; } timeToReloadSegment = true; } diff --git a/WorldSegment.cpp b/WorldSegment.cpp index 9b4ca879..a798ba46 100644 --- a/WorldSegment.cpp +++ b/WorldSegment.cpp @@ -4,6 +4,11 @@ #include "ContentLoader.h" #include "Creatures.h" +const GameState SegmentWrap::zeroState = +{ + {0,0,0},0,{0,0,0},{0,0,0},{0,0,0},0,0 +}; + ALLEGRO_BITMAP * fog = 0; Tile* WorldSegment::ResetTile(int32_t x, int32_t y, int32_t z, df::tiletype type) @@ -12,23 +17,23 @@ Tile* WorldSegment::ResetTile(int32_t x, int32_t y, int32_t z, df::tiletype type uint32_t ly = y; uint32_t lz = z; //make local - lx -= this->pos.x; - ly -= this->pos.y; - lz -= this->pos.z; + lx -= segState.Position.x; + ly -= segState.Position.y; + lz -= segState.Position.z; CorrectTileForSegmentRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz ); - if((int)lx < 0 || lx >= (uint32_t)this->size.x) { + if((int)lx < 0 || lx >= (uint32_t)segState.Size.x) { return 0; } - if((int)ly < 0 || ly >= (uint32_t)this->size.y) { + if((int)ly < 0 || ly >= (uint32_t)segState.Size.y) { return 0; } - if((int)lz < 0 || lz >= (uint32_t)this->size.z) { + if((int)lz < 0 || lz >= (uint32_t)segState.Size.z) { return 0; } - uint32_t index = lx + (ly * this->size.x) + ((lz) * this->size.x * this->size.y); + uint32_t index = lx + (ly * segState.Size.x) + ((lz) * segState.Size.x * segState.Size.y); Tile* tptr = & tiles[index]; @@ -46,9 +51,9 @@ Tile* WorldSegment::getTile(int32_t x, int32_t y, int32_t z) uint32_t ly = y; uint32_t lz = z; //make local - lx -= this->pos.x; - ly -= this->pos.y; - lz -= this->pos.z; + lx -= segState.Position.x; + ly -= segState.Position.y; + lz -= segState.Position.z; CorrectTileForSegmentRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz ); return getTileLocal(lx, ly, lz); @@ -60,9 +65,9 @@ Tile* WorldSegment::getTileRelativeTo(uint32_t x, uint32_t y, uint32_t z, dirRe int32_t ly = y; int32_t lz = z; //make local - lx -= this->pos.x; - ly -= this->pos.y; - lz -= this->pos.z; + lx -= segState.Position.x; + ly -= segState.Position.y; + lz -= segState.Position.z; CorrectTileForSegmentRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz ); switch (direction) { @@ -111,9 +116,9 @@ Tile* WorldSegment::getTileRelativeTo(uint32_t x, uint32_t y, uint32_t z, dirRe int32_t ly = y; int32_t lz = z; //make local - lx -= this->pos.x; - ly -= this->pos.y; - lz -= this->pos.z; + lx -= segState.Position.x; + ly -= segState.Position.y; + lz -= segState.Position.z; CorrectTileForSegmentRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz ); switch (direction) { @@ -158,17 +163,17 @@ Tile* WorldSegment::getTileRelativeTo(uint32_t x, uint32_t y, uint32_t z, dirRe Tile* WorldSegment::getTileLocal(uint32_t x, uint32_t y, uint32_t z) { - if((int)x < 0 || x >= (uint32_t)this->size.x) { + if((int)x < 0 || x >= (uint32_t)segState.Size.x) { return 0; } - if((int)y < 0 || y >= (uint32_t)this->size.y) { + if((int)y < 0 || y >= (uint32_t)segState.Size.y) { return 0; } - if((int)z < 0 || z >= (uint32_t)this->size.z) { + if((int)z < 0 || z >= (uint32_t)segState.Size.z) { return 0; } - uint32_t index = x + (y * this->size.x) + ((z) * this->size.x * this->size.y); + uint32_t index = x + (y * segState.Size.x) + ((z) * segState.Size.x * segState.Size.y); return getTile(index); } @@ -182,9 +187,9 @@ Tile* WorldSegment::getTile(uint32_t index) void WorldSegment::CorrectTileForSegmentOffset(int32_t& xin, int32_t& yin, int32_t& zin) { - xin -= segState.DisplayedSegment.x; - yin -= segState.DisplayedSegment.y; //DisplayedSegment.y; - zin -= segState.DisplayedSegment.z - 1; //need to remove the offset + xin -= segState.Position.x; + yin -= segState.Position.y; //Position.y; + zin -= segState.Position.z - 1; //need to remove the offset } void WorldSegment::CorrectTileForSegmentRotation(int32_t& x, int32_t& y, int32_t& z) @@ -193,16 +198,16 @@ void WorldSegment::CorrectTileForSegmentRotation(int32_t& x, int32_t& y, int32_t int32_t oldy = y; if(segState.DisplayedRotation == 1) { - x = size.x - oldy -1; + x = segState.Size.x - oldy -1; y = oldx; } if(segState.DisplayedRotation == 2) { - x = size.x - oldx -1; - y = size.y - oldy -1; + x = segState.Size.x - oldx -1; + y = segState.Size.y - oldy -1; } if(segState.DisplayedRotation == 3) { x = oldy; - y = size.y - oldx -1; + y = segState.Size.y - oldx -1; } } @@ -287,9 +292,9 @@ void WorldSegment::AssembleAllTiles() clock_t starttime = clock(); // x,y,z print prices - int32_t vsxmax = size.x-1; - int32_t vsymax = size.y-1; - int32_t vszmax = size.z-1; // grabbing one tile +z more than we should for tile rules + int32_t vsxmax = segState.Size.x-1; + int32_t vsymax = segState.Size.y-1; + int32_t vszmax = segState.Size.z-1; // grabbing one tile +z more than we should for tile rules for(int32_t vsz=0; vsz < vszmax; vsz++) { //add the fog to the queue if(ssConfig.fogenable && fog) { @@ -328,19 +333,19 @@ bool WorldSegment::CoordinateInsideSegment(uint32_t x, uint32_t y, uint32_t z) uint32_t ly = y; uint32_t lz = z; //make local - lx -= this->pos.x; - ly -= this->pos.y; - lz -= this->pos.z; + lx -= segState.Position.x; + ly -= segState.Position.y; + lz -= segState.Position.z; CorrectTileForSegmentRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz ); - if((int)lx < 0 || lx >= (uint32_t)this->size.x) { + if((int)lx < 0 || lx >= (uint32_t)segState.Size.x) { return 0; } - if((int)ly < 0 || ly >= (uint32_t)this->size.y) { + if((int)ly < 0 || ly >= (uint32_t)segState.Size.y) { return 0; } - if((int)lz < 0 || lz >= (uint32_t)this->size.z) { + if((int)lz < 0 || lz >= (uint32_t)segState.Size.z) { return 0; } @@ -353,19 +358,19 @@ bool WorldSegment::CoordinateInteriorSegment(uint32_t x, uint32_t y, uint32_t z, uint32_t ly = y; uint32_t lz = z; //make local - lx -= this->pos.x; - ly -= this->pos.y; - lz -= this->pos.z; + lx -= segState.Position.x; + ly -= segState.Position.y; + lz -= segState.Position.z; CorrectTileForSegmentRotation( (int32_t&)lx,(int32_t&)ly,(int32_t&)lz ); - if((int)lx < 0 + shellthick|| lx >= (uint32_t)this->size.x - shellthick) { + if((int)lx < 0 + shellthick|| lx >= (uint32_t)segState.Size.x - shellthick) { return 0; } - if((int)ly < 0 + shellthick|| ly >= (uint32_t)this->size.y - shellthick) { + if((int)ly < 0 + shellthick|| ly >= (uint32_t)segState.Size.y - shellthick) { return 0; } - if((int)lz < 0 /*bottom is "interior"*/ || lz >= (uint32_t)this->size.z - shellthick) { + if((int)lz < 0 /*bottom is "interior"*/ || lz >= (uint32_t)segState.Size.z - shellthick) { return 0; } return true; diff --git a/WorldSegment.h b/WorldSegment.h index da56bebc..b9461854 100644 --- a/WorldSegment.h +++ b/WorldSegment.h @@ -37,20 +37,15 @@ class WorldSegment bool loaded; bool processed; //these are the coordinates and size of the loaded segment - Crd3D pos; - Crd3D size; GameState segState; - WorldSegment(int x=0, int y=0, int z=0, int sizex=0, int sizey=0, int sizez=0) { - this->pos.x = x; - this->pos.y = y; - this->pos.z = z - sizez + 1; - this->size.x = sizex; - this->size.y = sizey; - this->size.z = sizez; - segState = ssState; + WorldSegment(GameState inState) { + segState = inState; + segState.Position.z = segState.Position.z - segState.Size.z + 1; - uint32_t memoryNeeded = sizex * sizey * sizez * sizeof(Tile); - tiles = (Tile*) malloc( memoryNeeded ); + + uint32_t newNumTiles = inState.Size.x * inState.Size.y * inState.Size.z; + uint32_t memoryNeeded = newNumTiles * sizeof(Tile); + tiles = (Tile*) malloc( memoryNeeded ); memset(tiles, 0, memoryNeeded); } @@ -64,7 +59,7 @@ class WorldSegment free(tiles); } - void Reset(int x=0, int y=0, int z=0, int sizex=0, int sizey=0, int sizez=0, bool hard=false) { + void Reset(GameState inState, bool hard=false) { //clear and free old data ClearBuildings(); ClearUnits(); @@ -73,7 +68,7 @@ class WorldSegment Tile::InvalidateAndDestroy(& tiles[i]); } - uint32_t newNumTiles = sizex * sizey * sizez; + uint32_t newNumTiles = inState.Size.x * inState.Size.y * inState.Size.z; uint32_t memoryNeeded = newNumTiles * sizeof(Tile); //if this is a hard reset, or if the size doesn't match what is needed, get a new segment if(hard || newNumTiles != getNumTiles()) { @@ -91,18 +86,12 @@ class WorldSegment } } - this->pos.x = x; - this->pos.y = y; - this->pos.z = z - sizez + 1; - this->size.x = sizex; - this->size.y = sizey; - this->size.z = sizez; - segState = ssState; - + segState = inState; + segState.Position.z = segState.Position.z - segState.Size.z + 1; } inline uint32_t getNumTiles() { - return size.x * size.y * size.z; + return segState.Size.x * segState.Size.y * segState.Size.z; } Tile* ResetTile(int32_t x, int32_t y, int32_t z, df::tiletype type=tiletype::OpenSpace); @@ -130,10 +119,12 @@ class WorldSegment // FIXME: make nicer. one day. maybe. class SegmentWrap { +private: + static const GameState zeroState; public: SegmentWrap() { - drawsegment = new WorldSegment(); - readsegment = new WorldSegment(); + drawsegment = new WorldSegment(zeroState); + readsegment = new WorldSegment(zeroState); drawmutex = al_create_mutex(); readmutex = al_create_mutex(); } @@ -144,8 +135,8 @@ class SegmentWrap al_destroy_mutex(readmutex); } void shutdown(){ - drawsegment->Reset(); - readsegment->Reset(); + drawsegment->Reset(zeroState); + readsegment->Reset(zeroState); } void lock() { al_lock_mutex(drawmutex); @@ -183,4 +174,4 @@ class SegmentWrap ALLEGRO_MUTEX * readmutex; WorldSegment * drawsegment; WorldSegment * readsegment; -}; +}; \ No newline at end of file diff --git a/common.h b/common.h index 8f78cfeb..f92d4da4 100644 --- a/common.h +++ b/common.h @@ -92,8 +92,8 @@ using namespace df::enums; #define SPRITEHEIGHT (TILETOPHEIGHT + WALLHEIGHT) #define WALL_CUTOFF_HEIGHT 15 -#define DEFAULT_SEGMENTSIZE 20 -#define DEFAULT_SEGMENTSIZE_Z 6 +#define DEFAULT_Size 20 +#define DEFAULT_Size_Z 6 #define MAPNAVIGATIONSTEP 1 #define MAPNAVIGATIONSTEPBIG 10 diff --git a/commonTypes.h b/commonTypes.h index 070b4a66..a37c74e4 100644 --- a/commonTypes.h +++ b/commonTypes.h @@ -238,11 +238,11 @@ struct GameConfiguration { struct GameState{ //properties of the currently viewed portion of the segment - Crd3D DisplayedSegment; + Crd3D Position; int DisplayedRotation; //the size of the next segment to load, and the map region - Crd3D SegmentSize; + Crd3D Size; Crd3D RegionDim; //position of the cursor diff --git a/main.cpp b/main.cpp index 3adc23b5..79fa33e7 100644 --- a/main.cpp +++ b/main.cpp @@ -173,14 +173,14 @@ bool loadfont(DFHack::color_ostream & output) void benchmark() { - ssState.DisplayedSegment.x = ssState.DisplayedSegment.y = 0; - ssState.DisplayedSegment.x = 110; - ssState.DisplayedSegment.y = 110; - ssState.DisplayedSegment.z = 18; + ssState.Position.x = ssState.Position.y = 0; + ssState.Position.x = 110; + ssState.Position.y = 110; + ssState.Position.z = 18; uint32_t startTime = clock(); int i = 20; while(i--) { - reloadDisplayedSegment(); + reloadPosition(); } FILE* fp = fopen("benchmark.txt", "w" ); @@ -269,7 +269,7 @@ static void main_loop(ALLEGRO_DISPLAY * display, Overlay * ovrlay, ALLEGRO_EVENT drawcredits(); ovrlay->Flip(); } else if( timeToReloadSegment ) { - reloadDisplayedSegment(); + reloadPosition(); al_clear_to_color(ssConfig.backcol); paintboard(); ovrlay->Flip(); @@ -289,7 +289,7 @@ static void main_loop(ALLEGRO_DISPLAY * display, Overlay * ovrlay, ALLEGRO_EVENT drawcredits(); al_flip_display(); } else if( timeToReloadSegment ) { - reloadDisplayedSegment(); + reloadPosition(); al_clear_to_color(ssConfig.backcol); paintboard(); al_flip_display(); @@ -401,9 +401,9 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms) ssConfig.Fullscreen = FULLSCREEN; ssState.ScreenH = RESOLUTION_HEIGHT; ssState.ScreenW = RESOLUTION_WIDTH; - ssState.SegmentSize.x = DEFAULT_SEGMENTSIZE; - ssState.SegmentSize.y = DEFAULT_SEGMENTSIZE; - ssState.SegmentSize.z = DEFAULT_SEGMENTSIZE_Z; + ssState.Size.x = DEFAULT_Size; + ssState.Size.y = DEFAULT_Size; + ssState.Size.z = DEFAULT_Size_Z; ssConfig.show_creature_names = true; ssConfig.show_osd = true; ssConfig.show_keybinds = false; @@ -446,8 +446,8 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms) return NULL; } //set debug cursor - debugCursor.x = ssState.SegmentSize.x / 2; - debugCursor.y = ssState.SegmentSize.y / 2; + debugCursor.x = ssState.Size.x / 2; + debugCursor.y = ssState.Size.y / 2; uint32_t version = al_get_allegro_version(); int major = version >> 24; @@ -459,7 +459,8 @@ static void * stonesense_thread(ALLEGRO_THREAD * main_thread, void * parms) al_set_new_display_flags( (ssConfig.Fullscreen && !ssConfig.overlay_mode ? ALLEGRO_FULLSCREEN : ALLEGRO_WINDOWED) - |(ssConfig.overlay_mode ? ALLEGRO_RESIZABLE : ALLEGRO_MINIMIZED) + |(ssConfig.overlay_mode ? 0 : ALLEGRO_RESIZABLE) + |(ssConfig.overlay_mode ? ALLEGRO_MINIMIZED : 0) |(ssConfig.opengl ? ALLEGRO_OPENGL : 0) |(ssConfig.directX ? ALLEGRO_DIRECT3D_INTERNAL : 0));