C/Lua Programmer Wanted for fixing function & savegame files

C/Lua Programmer Wanted for fixing function & savegame files

Postby qubodup » 01 Jun 2013, 01:23

Hello,

BosWars saves games as gzipped lua code. The result can lead to a function in the code having more arguments than are supported. The second to last argument need to be put in an array to fix this.

Unfortunately I don't have C programming experience but I believe I was able to clarify the task at hand. The bug is described in https://savannah.nongnu.org/bugs/?35623

Warning: messages are displayed in reverse date order.

To get the latest SVN version, see http://www.boswars.org/development.shtml for simple instructions.

If you know your C and what a Lua array looks like, it'd be great if you could take a look at this.
Besides fixing the bug, suggestions on how to handle different savegame file format versions might be helpful.

Thanks!
User avatar
qubodup
Global Moderator
 
Posts: 1671
Joined: 08 Nov 2009, 22:52
Location: Berlin, Germany

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby andrewj » 01 Jun 2013, 11:02

Your suggestion on how to fix this seems correct -- I am downloading the SVN to take a look, but my internet is extremely slow right now and haven't got past the zillion pngs yet...

Also, don't worry about keeping savegame compatibility -- aside from ensuring that old savegames gracefully won't work [e.g. use a different folder for them]. Compatibilty can require a lot of work, especially if you make an elaborate "future-proof" system like I once did (and which was mostly a waste of time), as users generally expect major releases to break savegames.
User avatar
andrewj
 
Posts: 194
Joined: 15 Dec 2009, 16:32
Location: Tasmania

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby qubodup » 21 Jun 2013, 11:14

Help is still wanted!
User avatar
qubodup
Global Moderator
 
Posts: 1671
Joined: 08 Nov 2009, 22:52
Location: Berlin, Germany

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby KroArtem » 21 Jun 2013, 12:15

Do you think it is worth fixing? BosWars is more or less dead, the engine is outdated and I don't see any active contributors (coders).
KroArtem
 
Posts: 375
Joined: 26 Aug 2010, 19:04

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby Sauer2 » 21 Jun 2013, 12:45

@KroArtem: The bug entry has some answering comments, so there might be still interest.
@qubodup: The first link seems to be dead.
From other ressources: You can't use more than 256 function arguments in Lua, because the number of arguments is saved in 8 bit (a char?) which would then overflow.

According to the Visual Studio 2013 keywords are redefined using macros, which is not allowed in C++11.
Also, I wasn't able to insert the precompiled libs, but maybe that's just me.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby qubodup » 21 Jun 2013, 17:28

KroArtem {l Wrote}:Do you think it is worth fixing? BosWars is more or less dead, the engine is outdated and I don't see any active contributors (coders).

Yes it's worth fixing. A few days ago a new release was uploaded and campaigns are being added. Boswars is the best FOSS 2D rts I know of.

Below is a statsvn screen of the repository activity (quickest visual stats I could throw together):
Image

Sauer2 {l Wrote}:@KroArtem: The bug entry has some answering comments, so there might be still interest.
@qubodup: The first link seems to be dead.

The link might have been down but now it's up.

I can't comment on anything programming related but perhaps your findings will be useful to somebody knowing C++ and able to help.
User avatar
qubodup
Global Moderator
 
Posts: 1671
Joined: 08 Nov 2009, 22:52
Location: Berlin, Germany

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby Sauer2 » 21 Jun 2013, 20:50

qubodup {l Wrote}:I can't comment on anything programming related but perhaps your findings will be useful to somebody knowing C++ and able to help.

I hope, but it also could make them flee in horror.
User avatar
Sauer2
 
Posts: 430
Joined: 19 Jan 2010, 14:02

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby Bertram » 22 Jun 2013, 15:39

Ok, here is where the SlotUsage faulty statement is coded:
engine\unit\unit_manager.cpp: line 123

Personnally, I like the idea of putting the second parameter up to the Nth one into a table as a try:
So one could replace this (line 126):
{l Code}: {l Select All Code}
   for (; it != ReleasedUnits.end(); ++it) {
      file->printf(", {Slot = %d, FreeCycle = %lu}", (*it)->Slot, (*it)->Refs);
   }
        file->printf(")\n");

by that:
{l Code}: {l Select All Code}
        bool first_parameter = true;
        file->printf(" { ");
        for (; it != ReleasedUnits.end(); ++it) {
                if (first_parameter) {
                      file->printf(" {Slot = %d, FreeCycle = %lu}", (*it)->Slot, (*it)->Refs);
                }
                else {
                      file->printf(", {Slot = %d, FreeCycle = %lu}", (*it)->Slot, (*it)->Refs);
                }
        }
        file->printf("} )\n");

(Yes, this code could be shorter but it's not the point. ;])

As the game is loaded through the LuaLoadFile() function which is in fact executing the script.
I assume the Slotusage() lua function has to be adapted to correctly load it:

In engine/unit/script_unit.cpp: line 1087
The static int CclSlotUsage(lua_State *l) function seems to load that part, as told in void UnitCclRegister(void) a few lines under.

The loop in line 1105 shall be changed to first open the table and then loop.
Does this already help?

Best regards,
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby Bertram » 24 Jun 2013, 09:38

Hi again,

qubodup {l Wrote}: A few days ago a new release was uploaded and campaigns are being added. Boswars is the best FOSS 2D rts I know of.

Well, if there is still a team behind boswars, have you contacted them to raise up this problem? Are they themselves stuck on this one?

Best regards,
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby silnarm » 15 Jul 2013, 03:58

Could someone please upload a savegame that is sufficiently deep into the game that lots of units have been killed (preferably recently) but not so bad that it can't be loaded any more.

This will speed things up considerably :)
silnarm
 
Posts: 7
Joined: 26 Feb 2010, 04:19

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby qubodup » 15 Jul 2013, 15:29

silnarm {l Wrote}:Could someone please upload a savegame that is sufficiently deep into the game that lots of units have been killed (preferably recently) but not so bad that it can't be loaded any more.

There is one, see "Attached Files" on https://savannah.nongnu.org/bugs/?35623

Bertram {l Wrote}:
qubodup {l Wrote}: A few days ago a new release was uploaded and campaigns are being added. Boswars is the best FOSS 2D rts I know of.

Well, if there is still a team behind boswars, have you contacted them to raise up this problem? Are they themselves stuck on this one?

There are no Bos-code experienced programmers around it seems http://archives.seul.org/bos/dev/Jun-2013/msg00006.html .
User avatar
qubodup
Global Moderator
 
Posts: 1671
Joined: 08 Nov 2009, 22:52
Location: Berlin, Germany

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby silnarm » 16 Jul 2013, 02:10

qubodup {l Wrote}:
silnarm {l Wrote}:Could someone please upload a savegame that is sufficiently deep into the game that lots of units have been killed (preferably recently) but not so bad that it can't be loaded any more.

There is one, see "Attached Files" on https://savannah.nongnu.org/bugs/?35623


I actually wanted one that still loaded, to test the save code, but I managed to make my own easily enough (yay for small maps).

Here you go.

Not tested very extensively, but it appears to function correctly. Let me know if there are any problems.
silnarm
 
Posts: 7
Joined: 26 Feb 2010, 04:19

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby qubodup » 17 Jul 2013, 02:47

Thanks a lot!
User avatar
qubodup
Global Moderator
 
Posts: 1671
Joined: 08 Nov 2009, 22:52
Location: Berlin, Germany

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby Bertram » 20 Jul 2013, 08:35

I actually wanted one that still loaded, to test the save code, but I managed to make my own easily enough (yay for small maps)


Cool, thanks for taking care of it. :)
User avatar
Bertram
VT Moderator
 
Posts: 1652
Joined: 09 Nov 2012, 12:26

Re: C/Lua Programmer Wanted for fixing function & savegame f

Postby KroArtem » 11 Aug 2013, 10:32

Just wanted to see how many errors would cppcheck find in boswars. Practically nothing, mainly style warnings and so on. I've started fixing them but then realized there are too many such warning.
Though I don't want to lose even such a small amount of work so here is the patch: fixes indentation, 1-2 unused variables, reduce scope of some variables.
Attachments
diff.patch
(23.29 KiB) Downloaded 428 times
KroArtem
 
Posts: 375
Joined: 26 Aug 2010, 19:04

Who is online

Users browsing this forum: No registered users and 1 guest