Compiling the OHRRPGCE from source

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

Praise the developers, the creators of the great, that they keep improving. But one thing seems to have gotten worse since QuickBasic! If you wanted to edit the icon of custom.exe or game.exe, you changed the icon file, compiled everything, and voilà: There was a customised icon. But this time it still uses the standard icon, even if the standard icons were changed and the old custom.exe and game.exe were deleted, so that it can build new ones! Where does it get the old icons from?
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

If I remember correctly, FreeBasic cannot handle icons at all
I also don't remember QuickBasic having any kind of icon support either.

The icons are inserted after the fact by an external program (Resource Hacker, I think?)

I'll admit it has been so long since I did it, I don't remember exactly what we did ;)
Last edited by Bob the Hamster on Fri Jul 26, 2019 9:54 am, edited 1 time in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Actually, FB does support setting the icon, using an .rc file, and fbgfx also will icon at the top-left of the window while running to the same icon.

When you compile game.exe yourself, game.ico is embedded. When you use Distribute Game, the icon compiled into game.exe is replaced using support/rcedit.exe.

But (unless you use "scons linkgcc=0"), game.ico is first compiled to build/gicon.obj using windres, which is then embedded.

I see that SConscript doesn't ensure that gicon.obj is rebuilt if game.ico changes. I'm fixing that now, thanks.
As a workaround, delete gicon.obj and re-run scons.
Last edited by TMC on Fri Jul 26, 2019 11:22 am, edited 1 time in total.
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

TMC wrote:As a workaround, delete gicon.obj and re-run scons.
Success! And don't forget cicon.obj for the icon of custom.exe!
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

This thread should be the place for all the questions about the source code. Can one of the developers tell me something about the "buffer()" command?

Like here, in this specific part of savegame.rbas:

Code: Select all

DIM z as integer = 3305
 FOR i as integer = 0 TO 3
  FOR j as integer = 0 TO statLast
   pv.hero(i).stat.cur.sta(j) = buffer(z): z += 1
  NEXT j
In the part before this, there are some of big numbers, which seem to make this script point at some data at an exact location. Is there a logic behind it?

When playing with buffer(), like letting game.exe print the result of buffer(0), buffer(1), buffer(2)... there are just some numbers, nearly all zero, but there are results again for buffer(34000), buffer(34001), etc. What is happening there?

Is it possible to access the heros HP stat, which is stored in the savegame (.rsav) file with this?
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Buffer() is just a big array of integers. It is filled with data from the old .sav file. The part of savegame.rbas you were reading was only about the old .sav format. A separate part of that file loads the newer .rsav format
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Hero stats are already loaded into SaveSlotPreview! E.g. the HP for hero slot 0 is pv.hero(0).stat.cur.hp. Slot 0 might be blank, you have to search pv.hero_id() to find the leader.
Last edited by TMC on Tue Jul 30, 2019 10:03 pm, edited 1 time in total.
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

TMC wrote:Hero stats are already loaded into SaveSlotPreview!
I wasn't able to proceed with pv.hero stuff, as there was an error when compiling

Code: Select all

hp1(i) = pv.hero(0).stat.cur.hp
: Array access, index expected, before '.'

But it is written like that elsewhere in the other scripts! What could have been missed?
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Sadly FB's error messages do not say where on the line of code the error is...

But was this inside one of the picksave_* functions? Then pv is an array (one SaveSlotPreview for each save slot), so you should write pv(i) or pv(st.pt) as appropriate instead of pv.
Last edited by TMC on Wed Jul 31, 2019 11:34 am, edited 1 time in total.
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

Yes! That was it! Indeed, this code came from the picksave function. Thank you!

While playing with the source, a stupid mistake came up while compiling.

Invalid assignment/conversion in

Code: Select all

hp1(i) = pv(i).hero(0).stat.cur.hp
However adding an empty string behind that did compile, like that

Code: Select all

hp1(i) = pv(i).hero(0).stat.cur.hp & " "
Does that make sense? Did I change the type through making a number marry a string?
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, that makes sense. You could also have written & "" instead of & " ".The & operator converts its arguments to strings, so is pretty convenient for conversions. The more explicit way to convert to string is

Code: Select all

STR(pv(i).hero(0).stat.cur.hp)
Last edited by TMC on Thu Aug 01, 2019 1:52 am, edited 1 time in total.
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

I'm playing around with the old 2013 source code again. But maybe this is wasn't changed until today.

In menustuf.rbas, there is the line:

Code: Select all

slot = first_slot_in_active_party()
Why not use this instead?

Code: Select all

slot = first_slot_in_party()
And in addition to that:

Code: Select all

buyst.room_to_hire = herocount&#40;3&#41; < 4 ANDALSO free_slots_in_party&#40;&#41; > 0
Why not dump these conditions? There is always enough room in the party! Put new heros in the reserve party, if there isn't any room in the first four slots.

I adress that, because I noticed people not knowing the OHRRPGCE and not knowing this game mechanic don't get it, why hireable heros can't be put in the reserve. Any thoughts?

Edit:
In 2013, there was a party limit of 41, which has been overcome by now according to the wiki. I found out, that the line

Code: Select all

 buyst.room_to_hire = first_free_slot_in_party < 37
would prevent the player to hire too many heros. Are there any other concerns with the hero party size?
(Edit2: Disable HTML, code now fine)
Last edited by Bird on Fri Nov 08, 2019 1:58 pm, edited 4 times in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Actually all the code you're referring to has been changed since so I couldn't find it. Can you at least tell the function names in future? Also, you need to tick "Disable HTML in this post" otherwise text between < and > will be removed. It mangled some of the code you posted.

But I did find the condition for checking for space in the party before hiring:

Code: Select all

  IF active_party_size&#40;&#41; = active_party_slots&#40;&#41; ORELSE free_slots_in_party&#40;&#41; <= 0 THEN
(This doesn't make much sense, since if the last part is true then the first part always is too.)

I agree that this limit isn't necessary. But I would add a Preference Bit to control it. You don't necessarily want to allow hiring into the reserve party.

The party size limit hasn't been increased, it's still 41. Where did you read that it has? But James and I were working on lifting that limit. It's quite tricky because of interactions with script commands like "swap out hero".
Last edited by TMC on Fri Nov 08, 2019 10:02 am, edited 2 times in total.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Right, the max number of her definitions was raised, but the size of the reserve part was not raised.

I agree it is a good idea to add a bitset to allow hiring into the reserve, allthough I suggest implementing it in the current source code Bird, not in the 2013 source code ;)
User avatar
Bird
Slime Knight
Posts: 227
Joined: Thu Jan 26, 2012 2:19 pm
Location: Germany

Post by Bird »

My imagination got out of control, after seeing a 512 on the wiki page called "What are the limits on various things?", subcategory "Heroes", that was a 60 on the 6-year-old revision of that wiki article. How embarrassing!

Maybe it would be a good step indeed to leave the playing ground and try some tweaks on the current version. But Freebasic isn't Hspeak. Messing up something of people, who know what they are doing, should be avoided. In the future, I will surely be able to contribute on the programming side.

By the way, the suggestion in my post above was bad. It's about

Code: Select all

buyst.room_to_hire = first_free_slot_in_party < 37
which was originally in the subfunction buystuff_buildmenu in menustuf.rbas

Code: Select all

buyst.room_to_hire = herocount&#40;3&#41; < 4 ANDALSO free_slots_in_party&#40;&#41; > 0
That suggetion doesn't stop the player from hiring heroes. Because if the player puts heroes from the active in the reserve, there are always free spaces in the active party, meaining that the first_free_slot_in_party is always lower than the given limit.
What worked was some counter to get the total number of heroes, active or reserve, and compare that again:

Code: Select all

DIM partysize as integer = 0
FOR o as integer = 0 TO 60
 IF hero&#40;o&#41; > 0 THEN
 partysize += 1
 NEXT i
END IF
buyst.room_to_hire = partysize < 37
That's probably all about the old source code. My project is finished. No more questions. Thank you, James and Ralph, for answering everything!
Post Reply