Compiling the OHRRPGCE from source
Moderators: marionline, SDHawk
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?
- Bob the Hamster
- Lord of the Slimes
- Posts: 7658
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
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 ;)
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.
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.
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.
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:
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?
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
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?
- Bob the Hamster
- Lord of the Slimes
- Posts: 7658
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
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.
I wasn't able to proceed with pv.hero stuff, as there was an error when compilingTMC wrote:Hero stats are already loaded into SaveSlotPreview!
Code: Select all
hp1(i) = pv.hero(0).stat.cur.hp
But it is written like that elsewhere in the other scripts! What could have been missed?
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.
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.
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
However adding an empty string behind that did compile, like that
Does that make sense? Did I change the type through making a number marry a string?
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
Code: Select all
hp1(i) = pv(i).hero(0).stat.cur.hp & " "
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.
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:
Why not use this instead?
And in addition to that:
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
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)
In menustuf.rbas, there is the line:
Code: Select all
slot = first_slot_in_active_party()
Code: Select all
slot = first_slot_in_party()
Code: Select all
buyst.room_to_hire = herocount(3) < 4 ANDALSO free_slots_in_party() > 0
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
(Edit2: Disable HTML, code now fine)
Last edited by Bird on Fri Nov 08, 2019 1:58 pm, edited 4 times in total.
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:
(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".
But I did find the condition for checking for space in the party before hiring:
Code: Select all
IF active_party_size() = active_party_slots() ORELSE free_slots_in_party() <= 0 THEN
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.
- Bob the Hamster
- Lord of the Slimes
- Posts: 7658
- Joined: Tue Oct 16, 2007 2:34 pm
- Location: Hamster Republic (Ontario Enclave)
- Contact:
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
which was originally in the subfunction buystuff_buildmenu in menustuf.rbas
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:
That's probably all about the old source code. My project is finished. No more questions. Thank you, James and Ralph, for answering everything!
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
Code: Select all
buyst.room_to_hire = herocount(3) < 4 ANDALSO free_slots_in_party() > 0
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(o) > 0 THEN
partysize += 1
NEXT i
END IF
buyst.room_to_hire = partysize < 37