Welcome to Phrogram Sign in | Join | Help
in Search


Writing user data files at runtime

Last post 05-12-2008, 1:14 PM by ZMan. 9 replies.
Sort Posts: Previous Next
  •  05-09-2008, 12:30 PM 6647

    Writing user data files at runtime

    ChrismasWhislter wrote in these 2 posts:

    http://phrogram.com/forums/post/6633.aspx

    Well, let me explain what my Phrogram does today.  It is a play-by-email game (all those fancy MMORGs are just a passing fad... play by e-mail is going to make a comeback!).  The program Boo! allows up to 15 players to plot what their character should do for the next turn.  This plot file is written to the \bin directory as a new text file.  That file would then be e-mailed as an attachment to the other (up to) 14 players.  On my system - I would receive the plot files for the other 14 players - and place them all in \bin.  When Boo! starts it automatically looks to the \bin directory for any new plot files.  It reads in all of them and updates a master game file of all the plot events.  When Boo! sees that all the plot files for a certain turn have been read in... then it allows the user to play that turn.

    http://phrogram.com/forums/post/6643.aspx

    But, my program Boo! expects that the users will be generating and adding 100s of text files (it is a play by e-mail game).  These should not be part of a single zipped file due to the complexity of a human to work with them.

     


    Managed DirectX and XNA ? Check out http://www.thezbuffer.com
  •  05-09-2008, 12:42 PM 6648 in reply to 6647

    Re: Writing user data files at runtime

    This is a bigger problem than you probably realise.

    Firstly /bin directories are in general for the application and any files that it needs to READ to get up and running. Writing files to the applicaton directory on a modern operating system has a lot of issues. In fact in Vista its actually not allowed (they have special code to work around it).

    1. Security - if applications can write to their own directory its possible for a virus or trojan to write their too and maybe even modify the EXE. Much better to keep thse directories read only

    2. If you store data in there then you can't easily back it up. Do you need to back up every directory to get these?

    3. What if multiple people use your computer - do you want the users seeing each others data

    4. What if they are just temporary working files - filling up application directories means each app has to manage those.

    5. People often want to write settings (INI) files there ut they suffer from the same problems - backup and user separation.

     

    So windows has some standards that apps should follow (though many dont and microsoft has to work around those and old programs that were written before the rules came out).

    1. App directories should be read only. If you try to write to  one in Vista it will redirect the write to a hidden user folder.

    2, 3 Datafiles should always be written to the users directories. If its something they need to see (in your case it is) then My Documents. If its settings files then the Application Data hidden directory.

    4. Temporary files get written to the windows temp directory.

    5. Use app data (like 2,3) or the registry http://blogs.msdn.com/oldnewthing/archive/2007/11/26/6523907.aspx

     

    From reading the desciption of your application you should be writing and reading the user data from My Documents NOT from the bin directory. I guess they save them there after they get them in email?

    There are 2 problems here for you I think:

    1. We dont give you any way to find the My Documents directory... we should

    2. We dont gve you any way to pop up the 'find file' dialog from windows (I dont think)

     

    Questions?

     


    Managed DirectX and XNA ? Check out http://www.thezbuffer.com
  •  05-12-2008, 9:00 AM 6664 in reply to 6647

    Re: Writing user data files at runtime

    how do i do that???????????GAMES BY EMAIL!
    Filed under:
  •  05-12-2008, 9:19 AM 6666 in reply to 6664

    Re: Writing user data files at runtime

    Games by email are done by sending a data file with your email that tells the other person the current state of the game. For example board games like chess and checkers work very well becuase you just send a copy of the new game board.

    There is nothing specific in Phrogram that allows you to do this.

    But one interesting 'add-on' library we could produce would be something that enabled email interaction... is this something people would like to see/be prepared to buy? What email clients do people use? Outlook/web mail?


    Managed DirectX and XNA ? Check out http://www.thezbuffer.com
  •  05-12-2008, 10:01 AM 6667 in reply to 6666

    Re: Writing user data files at runtime

    But one interesting 'add-on' library we could produce would be something that enabled email interaction... is this something people would like to see/be prepared to buy? What email clients do people use? Outlook/web mail?

    Outlook - with service providers Email address...Hotmail account...thats it.

    My son I think only uses hotmail.

    As for purchasing such a product...it would be great perhaps as a standard feature. To be honest I would not really buy any add ins...we have purchased a full licensed copy of Phrogram and if you made any significant upgrades...probably would purchase that if funds permit (i'm on quite a low income)

    But then again, I'm not a gamer really - although I write games...!

    My son is though, he likes to play web games, but don't think he plays many interactive games. Runescape is one though.

    ...but can see the future (think its here already) of being able to challenge friends either over the air with mobile games or via instant messanging...but not sure if email would capture the attention of the younger generation...maybe the older...?

    Don't know, I have no idea what the up and coming trends are (should do as I'm learning to program a lot more these days)...


    TomDad. Tom is my son...and I'm his Dad. So we are TomDad Software.
  •  05-12-2008, 11:38 AM 6669 in reply to 6648

    Re: Writing user data files at runtime

    ZMan,

    I agree with you in terms of the separation of various data and file types - based upon their usage and security issues.  Like I mentioned before, when I got my first file I/O working (by reading and writing to \bin, as (un)luck would have it) I was happy it worked and put off to later the chore of figuring out the right way to do it.

    To echo what I am hearing... while Windows has standards... we cannot take advantage of those standards in Phrogram.  Also, if I want to emulate the Windows standards in this area by having the following sub-directories under the game folder such as:

    c:\..\Boo                // main .exe

    c:\..\Boo\bin           // All read-only assets needed by Boo!

    c:\..\Boo\game1     // All read and write assets needed for game1

    c:\..\Boo\game2     // All read and write assets needed for game2

    the problem for me is that:

    1) This would allow other users of this computer access to the \game1 and \game2 subdirectories for possible corruption/hacking/error.

    2) Phrogram will not allow me to have relative directories - only fully specified.  So, if the person who installed the program Boo placed it in d:\program files\Boo then the program would not work.

    So, I *think* I am back to placing all my assets (both read only, and read/write in \bin) until this is fixed in the future.  Could you confirm my understanding of this?  I am *cool* with this, BTW, if this is the case.

    But, to reiterate, I would really like to use the Windows standards for my Phrogram programs as I recognize the value of them.  As a second best I would like to be able to emulate this separation as sub-directories under the directory that holds the application.

    Regards,


    ChristmasWhistler
    http://www.christmaswhistler.com
    (\ _/)
    (- . -) This is bunneh. Copy and paste him to
    (")-(") your signature, so that he may gain popularity and eventually rule the world
  •  05-12-2008, 12:00 PM 6670 in reply to 6669

    Re: Writing user data files at runtime

    What happens if you use "directory/filename.ext" - does that not read/write into the binary directory? Does it fail or write the programs in the wrong place?

    Or try "./directory/filename.ext"

    While there is no support for special windows directories I would have thought that everything should stay relative to the bin folder. (of course you can't actually make new folders from phrogram in code but you should be able to make them yourself).


    Managed DirectX and XNA ? Check out http://www.thezbuffer.com
  •  05-12-2008, 12:01 PM 6671 in reply to 6666

    Re: Writing user data files at runtime

    Jj9595 and ZMan,

    The way I think about the kind of game I am building is that it is turn based.  The wonderful advantage of a turn-based game is that you and all the other players do not have to be online (or awake!) at the same time for you to play the game.  You interact with the program to play previous turns and to plot your next turn.  When you are done plotting the latest turn, Boo! will save your latest plot file to the hard disk.  You then need to send that plot file to the other players.

    It could be minutes or hours (or days!) later when your other player(s) get around to reading in your plot file and have a go at their next turn.

    Again, the advantage is that everybody does not have to be online and active all at the same time.

    Boo! goes one step farther (beyond traditional turn-based games like chess or checkers) by simultaneously resolving each turn by pre-calculating the plots of all the players.  So, the actions of one player could disrupt the actions of other players.  This allows a player to sneak up behind another player and say "Boo!".  If successful, the player who was scared forefits the rest of their turn, drops all the gold they have at that time, and is moved to one of the muster points (usually a corner) to wait out the rest of the turn.

    To the point of providing a linkage between Phrogram and e-mail applications:

    Right now Boo! requires the user to find the plot file and "send" it to the other players.  It also requires the user to receive the other players' plot files and place them in the \bin directory.  This is cumbersome, I feel.  But, while the genre is indeed called play-by-email... it supports any method to get the text file to the other players.  I can see the opportunity in addition to e-mail:

    1) Send via a instant message chat.  (I have tested having your plot files written to the phrogram via an Alert() - which works)  I have thought in the far future to take advantage of the chat plug in.

    2) Be directly connected via a sockets connection over the Internet.  Ahh, but here, all the players would have to be online and awake at the same time.  Not too useful, me thinks.

    I *love* the idea of a SMS.  Wow, placing a game like Boo! on a cell phone would be *awesome*.  Someday... someday... But, I must get it working on the PC first!

    And, ZMan, I do not think an e-mail solution tied to a specific e-mail client is a good option.  Maybe if we could issue a mailto:christmaswhistler@yadda.com that would start up the the registered e-mail client of choice for this user with the To: list filled in and the latest plot file attached... that would be great.

    Regards,


    ChristmasWhistler
    http://www.christmaswhistler.com
    (\ _/)
    (- . -) This is bunneh. Copy and paste him to
    (")-(") your signature, so that he may gain popularity and eventually rule the world
  •  05-12-2008, 12:16 PM 6672 in reply to 6670

    Re: Writing user data files at runtime

    ZMan,

    I have not done any extensive testing... but I placed one of my .ini files in a newly created subdirectory named \ReadAssets.  It worked (Boo! found it without complaint) and without any modification.  I then created and moved the .ini file to a sub-sub-directory that I called \Read\Assets\game1.  It found that too.

    Now, my problem becomes if I have more than one file with the same name in those sub-directories... how do I get Boo! to find the correct one.

    Time permits... I will play and report back here.

    Regards,


    ChristmasWhistler
    http://www.christmaswhistler.com
    (\ _/)
    (- . -) This is bunneh. Copy and paste him to
    (")-(") your signature, so that he may gain popularity and eventually rule the world
  •  05-12-2008, 1:14 PM 6673 in reply to 6672

    Re: Writing user data files at runtime

    Fasinating... i know that Phrogram searches sub directories in the media library.. i didn't know it did the same thing in other folders... this could be a problem!

    as for telling the difference using the full but relative path should work

    e.g. use Read\Asserts\game1\file.ini rather then just file.ini


    Managed DirectX and XNA ? Check out http://www.thezbuffer.com
View as RSS news feed in XML