Home World Forum
Stars! AutoHost web forums

Jump to Stars! AutoHost


 
 
Home » Stars! Clones, Extensions, Modding » Stars! Extensions » Is starstat.exe the same as starstat.c
Is starstat.exe the same as starstat.c Thu, 05 November 2020 17:12 Go to previous message
ricks03 is currently offline ricks03

 
Officer Cadet 1st Year
Creator of TotalHost and Stars! utilities
Created TotalHost and Stars! utilities

Messages: 222
Registered: January 2012
Location: NC
https://wiki.starsautohost.org/wiki/Starstat_%26_Starinfo has the file and links to starstat.c. I used that code years ago to build the same functionality in Perl, but my starstat.pl doesn't handle if a .m (turn) file includes more than one turn.

When I look at the starstat.c code, one thing that starstat.exe does is has the ability to detect and include the information if a .M file includes one or more turns (and display ex:
"Game Year: 2408 to 2411")

In a .M file with a single turn, the value for fMulti is set to 0 in the first Block 8.

Unlike almost everything else, if a second turn is appended, the first turn's block 8 is modified, changing the value of fMulti to 1. The second turn then has a fMulti value of 0.

Oddly, if a third turn is added (and any additional turns after that as well) to the .M file, fMulti's value is ALSO 0.
So we have a .M file contents:
block 8: Turn =8, fMulti=1
block 8: Turn =9, fMulti=0
block 8: Turn =10, fMulti=0
block 8: Turn =11, fMulti=0
etc.

As best as I can tell, starstat.exe returns the turn year from the first block, and the last block. Be a lot easier if they were all fMulti=1 but the last one so you could tell which block was the last block, but whatever.

OK, when I then look at the c code in starstat.c for that result, it's

if (rtbof.dt == dtTurn && rtbof.fMulti)
{
fseek(in, -2, SEEK_END);
fread(&w, 1, 2, in);
printf(" to %u", w + 2400);
}


which, in my completely lousy and nonexistent c skills, says:
If this is a turn(.M) file, and fMulti is true, then go to the end of the file, back up 2 bytes, read forward two bytes, add 2400 to the result and display the result.

The thing I don't understand is that the last two bytes are the two bytes of Block 0, which are decidedly not the/a year. And the last byte of block 8 is the values of Shareware, Turn Submitted, etc, so clearly not the other turn result.

Clearly I'm failing here somewhere. Can someone better in c look at that code and help me understand exactly where starstat.exe is finding the information based on the above c code?

The reason I care? Because I have code that can detect for many of the known cheats and hacks in a stars turn. However, when I'm parsing through the .M file, if the game has a lot of players, and a lot of players have stopped submitting turns, the amount of time it takes to process a file is really really long. I have the other solution of effectively reading thorugh and puzlzing out which block 8 is the LAST block 8, but I'm hoping there's a better way.


[Updated on: Thu, 05 November 2020 17:12]




https://www.irelandbybicycle.com
http://totalhost.sinister.net:999
https://github.com/ricks03/TotalHost

Report message to a moderator

 
Read Message
Read Message
Previous Topic: Stars! AI
Next Topic: Fixing Stars!
Goto Forum:
  


Current Time: Thu Apr 18 21:17:17 EDT 2024