Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

problem with import/export globals

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
chronoboy
Into the past with a splash




Joined: 04 Jun 2010
Posts: 162
Location: Canada

PostPosted: Wed Oct 13, 2010 3:05 pm    Post subject: problem with import/export globals Reply with quote

For some reason when I export some global variables, then attempt to re-import them, I get some really huge numbers instead of the ones I saved.

Code:
global variable (100,system data)
global variable (101,flag 1)
global variable (102,flag 2)

script, check system data, begin
  import globals (5,100,102)
  if (system data >> 0), then
  begin
    show textbox (3)
    wait for textbox
  end
  else, begin
    system data := true
    flag 1 := 51
    flag 2 := 99
    export globals (5,100,102)
  end
end


Textbox 3 wrote:
flag 1: ${V101}
flag 2: ${V102}
System data loaded.


This is the response I get back:
Textbox 3 wrote:
flag 1: 24641912
flag 2: 131074
System data loaded.


Also, is it possible to run the RPG file twice and have both of them change global variables and effect the other game?

UPDATE: Well, it would seem that global variables from unused save files are not initialized to 0. If I export the globals in a new game script, they do persist in load game scripts.

New question: How do you detect if this is the players first game and the SAV file is fresh? My only guess would be to create a global variable of a very specific number and export it. During the new game script, verify if the global variable is set to this, and take action.
_________________
Current project: Chronoboy Adventures

Website: http://www.chronoboy.com/
Back to top
View user's profile Send private message Visit poster's website
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Oct 13, 2010 3:35 pm    Post subject: Re: problem with import/export globals Reply with quote

chronoboy wrote:
For some reason when I export some global variables, then attempt to re-import them, I get some really huge numbers instead of the ones I saved.
...

Textbox 3 wrote:
flag 1: ${V101}
flag 2: ${V102}
System data loaded.


This is the response I get back:
Textbox 3 wrote:
flag 1: 24641912
flag 2: 131074
System data loaded.


This sounds like a bug! However, when I test it myself, I am not seeing the strange large values.

What is the version number of the build that you are using? Ypsiliform? or a nightly? And if a nightly, which one?

Do you have any interesting messages in g_debug.txt or at the end of g_debug_archive.txt ?

chronoboy wrote:
Also, is it possible to run the RPG file twice and have both of them change global variables and effect the other game?


I am not sure what you mean by this. Can you explain more?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chronoboy
Into the past with a splash




Joined: 04 Jun 2010
Posts: 162
Location: Canada

PostPosted: Wed Oct 13, 2010 4:34 pm    Post subject: Re: problem with import/export globals Reply with quote

James Paige wrote:
What is the version number of the build that you are using? Ypsiliform? or a nightly? And if a nightly, which one?

I am using Ypsiliform+2, 20100208

James Paige wrote:
Do you have any interesting messages in g_debug.txt or at the end of g_debug_archive.txt ?

Nothing at all of interest. I notice this type of error when I used to work in QB awhile back. When attempting to read from a binary file a point which does not exist in the file itself, it would provide bogus data from the disc after the files EOF, oddly enough. Seems that FB in binary mode does not respect EOF either. You would not see the same number or may even see 0, if the section of your disk is indeed zeroed out. This may also be a Windows/DOS I/O bug tho, as I am currently going through the windows version and have not tested it through Linux yet.

James Paige wrote:
chronoboy wrote:
Also, is it possible to run the RPG file twice and have both of them change global variables and effect the other game?


I am not sure what you mean by this. Can you explain more?


Say, we have GAME.RPG and GAME.SAV in the same folder, we open two copies of GAME.RPG, thus having two OHR game windows with GAME.RPG in them and running. Now say, one of these copies goes and changes a global variable in the GAME.SAV file, and the second copy goes and reads from it. In theory, the second copy should of been able to grab the global variables which the first copy just saved, correct?
_________________
Current project: Chronoboy Adventures

Website: http://www.chronoboy.com/
Back to top
View user's profile Send private message Visit poster's website
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Wed Oct 13, 2010 5:04 pm    Post subject: Re: problem with import/export globals Reply with quote

chronoboy wrote:
... This may also be a Windows/DOS I/O bug tho, as I am currently going through the windows version and have not tested it through Linux yet.


Good point. I have only tested the problem on Linux so far.
What windows are you using? XP? Win7?

Also, the nightly builds have had a pretty substantial re-write of the saving and loading code, including import globals and export globals, so I might have just fixed it then. Night builds now save in a different format called RSAV, and the old SAV file does not matter anymore. Would you be willing to test with a current nightly build and see if this problem is still happening?

chronoboy wrote:
Say, we have GAME.RPG and GAME.SAV in the same folder, we open two copies of GAME.RPG, thus having two OHR game windows with GAME.RPG in them and running. Now say, one of these copies goes and changes a global variable in the GAME.SAV file, and the second copy goes and reads from it. In theory, the second copy should of been able to grab the global variables which the first copy just saved, correct?


Oh! I understand now!

Yes two instances of game.exe running the same game could indeed communicate with each other using this method. I see no problem with that at all.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chronoboy
Into the past with a splash




Joined: 04 Jun 2010
Posts: 162
Location: Canada

PostPosted: Wed Oct 13, 2010 5:36 pm    Post subject: Re: problem with import/export globals Reply with quote

On WinXP Pro SP2.

James Paige wrote:
chronoboy wrote:
Say, we have GAME.RPG and GAME.SAV in the same folder, we open two copies of GAME.RPG, thus having two OHR game windows with GAME.RPG in them and running. Now say, one of these copies goes and changes a global variable in the GAME.SAV file, and the second copy goes and reads from it. In theory, the second copy should of been able to grab the global variables which the first copy just saved, correct?


Oh! I understand now!

Yes two instances of game.exe running the same game could indeed communicate with each other using this method. I see no problem with that at all.


Hmm, most interesting. Thus the start of an OHR online RPG using a Samba(Window Server) in a home network. On each step, I could update the other players X,Y,D via global variables shared between instances. To make it available on the internet, VNC could be used. Plotscript could easily be used to handle a chat interface and PvP battles. Would an online game count in the heart of OHR contest. Raspberry!

Even more so, I could think of many ways besides online play that this could be used for. Remember Pokemon stadium was able to read Gameboy saves? This could be used in such a way to be-able to trade items from one save file to another interactively, mind you this could also be done in single instance mode too.
_________________
Current project: Chronoboy Adventures

Website: http://www.chronoboy.com/
Back to top
View user's profile Send private message Visit poster's website
Pepsi Ranger
Reality TV Host




Joined: 05 Feb 2003
Posts: 493
Location: South Florida

PostPosted: Wed Oct 13, 2010 8:31 pm    Post subject: Reply with quote

chronoboy wrote:
Would an online game count in the heart of OHR contest.


If you were able to make this work (and still keep it RPG-like), then I would consider allowing it in the contest. Seems like a worthwhile experiment in any case.
_________________
Progress Report:

The Adventures of Powerstick Man: Extended Edition

Currently Updating: General sweep of the game world and dialogue boxes. Adding extended maps.

Tightfloss Maiden

Currently Updating: Chapter 2
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Thu Oct 14, 2010 3:37 am    Post subject: Re: problem with import/export globals Reply with quote

chronoboy wrote:
I notice this type of error when I used to work in QB awhile back. When attempting to read from a binary file a point which does not exist in the file itself, it would provide bogus data from the disc after the files EOF, oddly enough. Seems that FB in binary mode does not respect EOF either.


FB file IO is a wrapper around C file IO, which does not read bogus data past the end of a file. Instead, FB will zero-fill any buffer as required if the file is too short.

This cause of this bug would be that each saveslot is stored at offset 60000*slot in the .SAV file. So when a slot is created (eg. autosave which is slot 31) the file is extended up the the needed length, and all slots before that one which don't yet exist are filled with garbage. The new RSAV format doesn't suffer this problem.

Quote:
Hmm, most interesting. Thus the start of an OHR online RPG using a Samba(Window Server) in a home network. On each step, I could update the other players X,Y,D via global variables shared between instances. To make it available on the internet, VNC could be used. Plotscript could easily be used to handle a chat interface and PvP battles. Would an online game count in the heart of OHR contest. :P


Good luck! I started working on a game that used a similar gimmick once; learning php and writing the server in it (save files weren't to be shared in real time) killed the project :P
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group