Skip to content

Commit

Permalink
fixed issue #27 (lowered web fps) | dev update
Browse files Browse the repository at this point in the history
  • Loading branch information
AppOfficer committed Aug 2, 2023
1 parent 4815b7a commit b49bc83
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 42 deletions.
69 changes: 40 additions & 29 deletions LGweb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ int LGclient::GAME() {
int midact = 0;
int smsx = 0, smsy = 0; bool moved = false;
std::chrono::steady_clock::duration prsttm;
for(; is_run(); /*delay_fps(std::min(LGgame::gameSpeed + 0.5, 120.5))*/) {
for(; is_run(); delay_fps(std::min(LGgame::gameSpeed + 0.5, 120.5))) {
movLin=LGgame::playerCoo[playerNumber].x;
movCol=LGgame::playerCoo[playerNumber].y;

Expand Down Expand Up @@ -740,35 +740,46 @@ int LGclient::GAME() {
}
} {
std::chrono::nanoseconds timePassed = std::chrono::steady_clock::now().time_since_epoch() - LGgame::beginTime;
cleardevice();
printMap(LGgame::cheatCode, LGgame::playerCoo[playerNumber]);
LGgame::ranklist();
int screenszr = 1600 * LGGraphics::mapDataStore.mapSizeX;
static int fpslen;
static int turnlen;
static int rspeedlen;
setfillcolor(LGGraphics::bgColor);
bar(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen - 10, 0, screenszr, 20 * LGGraphics::mapDataStore.mapSizeY);
setfont(20 * LGGraphics::mapDataStore.mapSizeY, 0, "Quicksand");
timePassed = std::chrono::steady_clock::now().time_since_epoch() - LGgame::beginTime;
fpslen = textwidth(("FPS: " + to_string(getfps())).c_str());
turnlen = textwidth(("Turn " + to_string(LGgame::curTurn) + ".").c_str());
rspeedlen = textwidth(("Real Speed: " + to_string(LGgame::curTurn * 1.0L / (timePassed.count() / 1000000000.0L))).c_str()); setfillcolor(RED);
setfillcolor(GREEN);
bar(screenszr - rspeedlen - 10, 0, screenszr, 20 * LGGraphics::mapDataStore.mapSizeY);
rectangle(screenszr - rspeedlen - 10, 0, screenszr, 20 * LGGraphics::mapDataStore.mapSizeY);
setfillcolor(RED);
bar(screenszr - rspeedlen - 10 - fpslen - 10, 0, screenszr - rspeedlen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
rectangle(screenszr - rspeedlen - 10 - fpslen - 10, 0, screenszr - rspeedlen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
setfillcolor(BLUE);
bar(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen - 10, 0, screenszr - rspeedlen - 10 - fpslen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
rectangle(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen - 10, 0, screenszr - rspeedlen - 10 - fpslen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
settextjustify(CENTER_TEXT, TOP_TEXT);
xyprintf(screenszr - rspeedlen / 2 - 5, 0, "Real Speed: %Lf", LGgame::curTurn * 1.0L / (timePassed.count() / 1000000000.0L));
xyprintf(screenszr - rspeedlen - 10 - fpslen / 2 - 5, 0, "FPS: %f", getfps());
xyprintf(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen / 2 - 5, 0, "Turn %d.", LGgame::curTurn);
int needFlushToTurn = ceil(timePassed.count() / 1000000000.0L * LGgame::gameSpeed);
int lackTurn = LGgame::curTurn - needFlushToTurn;
if(lackTurn < 0);
else {
while(lackTurn > 0) {
timePassed = std::chrono::steady_clock::now().time_since_epoch() - LGgame::beginTime;
needFlushToTurn = ceil(timePassed.count() / 1000000000.0L * LGgame::gameSpeed);
lackTurn = LGgame::curTurn - needFlushToTurn;
}
cleardevice();
printMap(LGgame::cheatCode, LGgame::playerCoo[0]);
LGgame::ranklist();
int screenszr = 1600 * LGGraphics::mapDataStore.mapSizeX;
static int fpslen;
static int turnlen;
static int rspeedlen;
setfillcolor(LGGraphics::bgColor);
bar(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen - 10, 0, screenszr, 20 * LGGraphics::mapDataStore.mapSizeY);
setfont(20 * LGGraphics::mapDataStore.mapSizeY, 0, "Quicksand");
timePassed = std::chrono::steady_clock::now().time_since_epoch() - LGgame::beginTime;
fpslen = textwidth(("FPS: " + to_string(getfps())).c_str());
turnlen = textwidth(("Turn " + to_string(LGgame::curTurn) + ".").c_str());
rspeedlen = textwidth(("Real Speed: " + to_string(LGgame::curTurn * 1.0L / (timePassed.count() / 1000000000.0L))).c_str()); setfillcolor(RED);
setfillcolor(GREEN);
bar(screenszr - rspeedlen - 10, 0, screenszr, 20 * LGGraphics::mapDataStore.mapSizeY);
rectangle(screenszr - rspeedlen - 10, 0, screenszr, 20 * LGGraphics::mapDataStore.mapSizeY);
setfillcolor(RED);
bar(screenszr - rspeedlen - 10 - fpslen - 10, 0, screenszr - rspeedlen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
rectangle(screenszr - rspeedlen - 10 - fpslen - 10, 0, screenszr - rspeedlen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
setfillcolor(BLUE);
bar(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen - 10, 0, screenszr - rspeedlen - 10 - fpslen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
rectangle(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen - 10, 0, screenszr - rspeedlen - 10 - fpslen - 10, 20 * LGGraphics::mapDataStore.mapSizeY);
settextjustify(CENTER_TEXT, TOP_TEXT);
xyprintf(screenszr - rspeedlen / 2 - 5, 0, "Real Speed: %Lf", LGgame::curTurn * 1.0L / (timePassed.count() / 1000000000.0L));
xyprintf(screenszr - rspeedlen - 10 - fpslen / 2 - 5, 0, "FPS: %f", getfps());
xyprintf(screenszr - rspeedlen - 10 - fpslen - 10 - turnlen / 2 - 5, 0, "Turn %d.", LGgame::curTurn);
}
}
} return 0;
}
return 0;
}

#endif
6 changes: 3 additions & 3 deletions LocalGen.dev
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ UnitCount=9
Major=4
Minor=0
Release=0
Build=2094
Build=2100
LanguageID=1033
CharsetID=1252
CompanyName=LocalGen-dev
FileVersion=4.0.0.2094
FileVersion=4.0.0.2100
FileDescription=Local Generals.io (new ver.)
InternalName=
LegalCopyright=Copyright (c) 2023 LocalGen-dev
LegalTrademarks=
OriginalFilename=
ProductName=Local Generals.io (new ver.)
ProductVersion=4.0.0.2094
ProductVersion=4.0.0.2100
AutoIncBuildNr=1
SyncProduct=1

Expand Down
4 changes: 2 additions & 2 deletions LocalGen.layout
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ CursorRow=28
TopLine=19
LeftChar=1
[Editor_7]
CursorCol=49
CursorRow=20
CursorCol=25
CursorRow=22
TopLine=12
LeftChar=1
[Editor_3]
Expand Down
8 changes: 4 additions & 4 deletions LocalGen_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
#define LOCALGEN_PRIVATE_H

/* VERSION DEFINITIONS */
#define VER_STRING "4.0.0.2095"
#define VER_STRING "4.0.0.2100"
#define VER_MAJOR 4
#define VER_MINOR 0
#define VER_RELEASE 0
#define VER_BUILD 2095
#define VER_BUILD 2100
#define COMPANY_NAME "LocalGen-dev"
#define FILE_VERSION "4.0.0.2095"
#define FILE_VERSION "4.0.0.2100"
#define FILE_DESCRIPTION "Local Generals.io (new ver.)"
#define INTERNAL_NAME ""
#define LEGAL_COPYRIGHT "Copyright (c) 2023 LocalGen-dev"
#define LEGAL_TRADEMARKS ""
#define ORIGINAL_FILENAME ""
#define PRODUCT_NAME "Local Generals.io (new ver.)"
#define PRODUCT_VERSION "4.0.0.2095"
#define PRODUCT_VERSION "4.0.0.2100"

#endif /*LOCALGEN_PRIVATE_H*/
8 changes: 4 additions & 4 deletions LocalGen_private.rc
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ A ICON "LocalGen.ico"
// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS...
//
1 VERSIONINFO
FILEVERSION 4,0,0,2095
PRODUCTVERSION 4,0,0,2095
FILEVERSION 4,0,0,2100
PRODUCTVERSION 4,0,0,2100
FILETYPE VFT_APP
{
BLOCK "StringFileInfo"
{
BLOCK "040904E4"
{
VALUE "CompanyName", "LocalGen-dev"
VALUE "FileVersion", "4.0.0.2095"
VALUE "FileVersion", "4.0.0.2100"
VALUE "FileDescription", "Local Generals.io (new ver.)"
VALUE "InternalName", ""
VALUE "LegalCopyright", "Copyright (c) 2023 LocalGen-dev"
VALUE "LegalTrademarks", ""
VALUE "OriginalFilename", ""
VALUE "ProductName", "Local Generals.io (new ver.)"
VALUE "ProductVersion", "4.0.0.2095"
VALUE "ProductVersion", "4.0.0.2100"
}
}
BLOCK "VarFileInfo"
Expand Down

0 comments on commit b49bc83

Please sign in to comment.