Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 30 31 [32] 33 34 ... 81

Author Topic: Cloud Scream > Development on Pause  (Read 86935 times)

SolarShado

  • Bay Watcher
  • Psi-Blade => Your Back
    • View Profile
Re: Cloud Scream: > Another Trainwreck
« Reply #465 on: December 05, 2009, 11:08:14 pm »

Oops ^_^" heh, totally forgot that bit order issue...
Logged
Avid (rabid?) Linux user. Preferred flavor: Arch

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > Another Trainwreck
« Reply #466 on: December 06, 2009, 12:55:32 am »

I'm not sure of everything said, but it all sounds very promising. I'll look into it all in the morning.
I've had the most wonderful day in a long while, and I feel very refreshed.
Things are going to start being done soon.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > Another Trainwreck
« Reply #467 on: December 06, 2009, 11:51:58 am »

Alfie has given me some examples, and handed me some nice tutorials, and the save system is underway.
I was thinking this would be much harder, and currently, it could go either way.

Thanks though, I appreciate the helps.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > Save Me! Lots of progress.
« Reply #468 on: December 06, 2009, 01:36:38 pm »

I have saving and loading working!
Sort of.
I need to finish up the functions, and some other stuffs, but the capabilities are there now.

Don't kill me for the blasphemy I am about to show you guys.

I am saving the ints of my class as char maps in text documents.
About 2.71 megs for a local map. So far.

But look at the results:
Spoiler (click to show/hide)
Spoiler (click to show/hide)
Spoiler (click to show/hide)

I will probably make a more space efficient saver later, but for now it will be sloppy.
You can always delete the files if you don't want them.

I'm going to look further into stringstreams.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > Save Me! Lots of progress.
« Reply #469 on: December 06, 2009, 02:45:49 pm »

I've got tons of work to do, but it is currently saving the local maps as individual files, which can be loaded when you reenter an area.
It will do the gen all over again (using the same seed mind you) but then you can press the load key to
have it load back up your map.

There will be many changes before this thing is ready for public use.
Each local map saved will take around 6 megs I think.
The universe counts as a local map for all purposes.
So around 20 megs if you have 3 games saved.
I'm going to go dig in my DF folder and find out the file size of Toady's saves.

Any input?
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > Save Me! Lots of progress.
« Reply #470 on: December 06, 2009, 03:32:46 pm »

I'm going to just keep adding new posts, otherwise it won't show up on the forum as new.
An alternative solution would be very nice.

Here is the latest and coolest screenshot:
Spoiler (click to show/hide)

It's a side-by-side of the type and sort files for a given chunk of map.
Type is the actual material of a tile.
Sort is the variety of that material.
The " " character represents sort 0, which is default for empty tiles,
but other tiles can also have this sort.
It is basically default.

Can somebody please provide me some input?
I feel very alone right now.
« Last Edit: December 06, 2009, 03:35:06 pm by Outcast Orange »
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

LegoLord

  • Bay Watcher
  • Can you see it now?
    • View Profile
Re: Cloud Scream: > To Be Saved.
« Reply #471 on: December 06, 2009, 03:56:48 pm »

6 megabytes per local map, you say?  That sounds reasonably small.  Granted I'm a little hazy on how different file sizes relate.

If my math is right that's smaller than an inventor part file, which is about 12 times the size of a five-page wordperfect document.  Sounds pretty good to me.
Logged
"Oh look there is a dragon my clothes might burn let me take them off and only wear steel plate."
And this is how tinned food was invented.
Alternately: The Brick Testament. It's a really fun look at what the bible would look like if interpreted literally. With Legos.
Just so I remember

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > To Be Saved.
« Reply #472 on: December 06, 2009, 05:00:58 pm »

Yeah, that's about the size of an audio file.

I'm having trouble with binary saving, but I should have it functional soon.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Cloud Scream: > To Be Saved.
« Reply #473 on: December 06, 2009, 05:58:06 pm »

That's pretty impressive!  Binary isn't too bad though, iirc this is the tutorial I used when I had to figure it out.  And 6mb isn't bad, since you're saving the map.

Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > To Be Saved.
« Reply #474 on: December 06, 2009, 06:07:21 pm »

Here's where I'm stuck, though timmeh's advice might unstuck me.

Something in this block of code is causing a crash.
It compiles and runs fine, but when it gets here, it goes dead-bang.

Code: [Select]
//create 1D binary array for cohesion
bool array[3500000];
for(int currentx=0;currentx<145;currentx++){
for(int currenty=5;currenty<145;currenty++){
for(int currentz=5;currentz<145;currentz++){
    array[currentz+(151*currenty)+(22801*currentx)] = localtile[currentx][currenty][currentz].getstuck();
}}}

//save array to binary file
stringstream stuckfile;
stuckfile << "C" << " " << Earth.xcur << " " << Earth.ycur << " " << Earth.zcur << ".bin";
ofstream mybinfile(stuckfile.str().c_str(),ios::out|ios::binary|ios::ate);
mybinfile.open(stuckfile.str().c_str());
mybinfile.write((char*)&array,3442951);
mybinfile.close();

The second part is suspect, especially the (char*) &array line, since this is a bool ordeal.

Any help you can offer is appreciated.

EDIT: I was digging around in the ToA files, and am now thoroughly terrified of timmeh.
Those save functions are crazy. I have no idea.
« Last Edit: December 06, 2009, 06:19:15 pm by Outcast Orange »
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

monkey

  • Bay Watcher
    • View Profile
Re: Cloud Scream: > To Be Saved.
« Reply #475 on: December 06, 2009, 07:27:56 pm »

hi,
sizeof(bool) could be != 1
for large arrays of booleans use bitset, it uses 1/8th of the space
Code: [Select]
     include <bitset>

    std::bitset<145*145> stuckBits;
    stuckBits.reset();
     for(int currentx=0;currentx<145;currentx++){
          for(int currenty=5;currenty<145;currenty++){
               for(int currentz=5;currentz<145;currentz++){
                       stuckBits[currentz+(151*currenty)+(22801*currentx)] = localtile[currentx][currenty][currentz].getstuck();
                 }
            }
       }

    std::string filename = string("C") + " " Earth.xcur + " " + Earth.ycur + " " + Earth.zcur + ".bin"
    ofstream mybinfile(filename.c_str(),ios::binary|ios::ate);
    mybinfile << stuckBits;
    mybinfile.close();

and its not necessary to specify magic numbers like 22801 / 3442951, leave it at 151*151, your compiler takes care of it (http://en.wikipedia.org/wiki/Constant_folding), its more declarative and less error prone.

« Last Edit: December 06, 2009, 07:30:25 pm by monkey »
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Cloud Scream: > To Be Saved.
« Reply #476 on: December 06, 2009, 07:53:56 pm »

EDIT: I was digging around in the ToA files, and am now thoroughly terrified of timmeh.  Those save functions are crazy. I have no idea.

:P  The code was a bit of a mess, but it's functional, and if I can explain it it might make a little more sense...

Let's see...

Code: (Saving...) [Select]
ofstream savefile("data\\save.dat", ios::out | ios::binary);

savefile.write(reinterpret_cast<char *>(&Game.plyr_x), sizeof(int) );
savefile.write(reinterpret_cast<char *>(&Game.plyr_y), sizeof(int) );

savefile.write(reinterpret_cast<char *>(&Game.current_map), sizeof(dungeon_map) );

int logvecsize = Game.longlog.size();
savefile.write(reinterpret_cast<char *>(&logvecsize), sizeof(int) );
for(int i=0; i<logvecsize; i++)
{
    int length = Game.longlog[i].length();
    savefile.write(reinterpret_cast<char *>(&length), sizeof(int) );

    for(int j=0; j<length; j++)
    {
       savefile.write(reinterpret_cast<char *>(&Game.longlog[i].at(j)), sizeof(char) );
    }
}

savefile.close();
The first line opens the file for output in binary mode.  The next two save the player's x and y positions.  The fourth is just to show that you can save a class/structure just as easily as an integer, with some limitations I'll mention in a minute.

The next bit is a little more complicated.  I'm trying to save the vector of strings I use to store the message log, but neither vectors nor strings can be saved the same way integers can, because they're dynamic (can change size).  First I get and save the size of the vector, just like I would a normal integer.  Next I loop through the vector, saving the strings one at a time.  It works almost just like the vector, first I write the length of the string to the file, then each character in the string.

The last line saves and closes the file.

Code: (Loading...) [Select]
ifstream loadfile("data\\save.dat", ios::in | ios::binary);

loadfile.read(reinterpret_cast<char *>(&Game.plyr_x), sizeof(int) );
loadfile.read(reinterpret_cast<char *>(&Game.plyr_y), sizeof(int) );

dungeon_map newmap;
loadfile.read(reinterpret_cast<char *>(&newmap), sizeof(dungeon_map) );
memcpy(&Game.current_map, &newmap, sizeof(dungeon_map));
Game.current_map = newmap;

Game.longlog.clear();
int logvecsize;
loadfile.read(reinterpret_cast<char *>(&logvecsize), sizeof(int) );
for(int i=0; i<logvecsize; i++)
{
    int length;
    loadfile.read(reinterpret_cast<char *>(&length), sizeof(int));

    char log[length+1];
    for(int j=0; j<length; j++)
    {
        loadfile.read(reinterpret_cast<char *>(&log[j]), sizeof(char));
    }
    log[length] = '\0';
    Game.longlog.push_back(string(log));
}

loadfile.close();
I know, this one looks even worse... in all honesty though it's not too bad.  The first line opens the file for input in binary mode.  The next two load the player's position.  The next block is a little weird, but only because it's different.  Basically, for a reason I can't remember at the moment, I couldn't load the map directly into the 'Game' structure's 'current_map' member.  So I create a blank map, load the one from the file into it instead, then copy the information from it into the Game.current_map one.  I can't really remember why it works quite like that, with the memcpy call, but it works.

The next thing I do is clear the log vector, in case the player is loading in the middle of a game.  Then I load the size of the saved vector, and load the strings.  The string loading is a little weird too, but basically, I load the length, make a c-string thats one character longer (so I can terminate it after putting the rest of the letters in), and then load the letters into it one at a time.  Once I'm done, I convert the c-string into a normal string and push it onto the vector.

As you've probably (hopefully...) guessed, the last line closes the file.

The limitation I mentioned earlier:  Just like you have to save strings, vectors and other dynamic data types manually, any class or structure with a dynamic data type member has to be saved manually.  This is made a lot easier if you're using classes, cause you can create save and load functions that take the file variable as an argument, and break it down further.

See?  Or did I just make it worse?  :P


[EDIT]:  Here's an example of loading with a class function...
Code: (From the loading code...) [Select]
for(int i=0; i<EQUIPMENTSLOTS; i++)
{
    Game.plyr_equipment[i] = EmptySlot;
    if(Game.plyr_equipped[i]==true)
    {
        Game.plyr_equipment[i].load(loadfile);
    }
}
Code: (The item.load() function) [Select]
void item::load(ifstream &File)
{
    File.read(reinterpret_cast<char *>(&name), sizeof(char[10]) );
    File.read(reinterpret_cast<char *>(&symbol), sizeof(char) );

    File.read(reinterpret_cast<char *>(&type), sizeof(int) );
    File.read(reinterpret_cast<char *>(&ammo_type), sizeof(int) );
    File.read(reinterpret_cast<char *>(&equip_slot), sizeof(int) );

    File.read(reinterpret_cast<char *>(&effects), sizeof( int[EFFECTTYPES]) );
    item_spell.load(File);

    File.read(reinterpret_cast<char *>(&uses), sizeof(int) );

    File.read(reinterpret_cast<char *>(&x), sizeof(int) );
    File.read(reinterpret_cast<char *>(&y), sizeof(int) );

    File.read(reinterpret_cast<char *>(&value), sizeof(int) );
    File.read(reinterpret_cast<char *>(&weight), sizeof(int) );
}
Actually, there's a second tier here, cause the item load the spell that's tied to it with the spell class' load function.  Anyways, just figured I'd post this in case you wanted an example.
« Last Edit: December 06, 2009, 08:05:34 pm by timmeh »
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Outcast Orange

  • Bay Watcher
  • [SOMETIMES_SQUID]
    • View Profile
    • The Outcast Orange
Re: Cloud Scream: > To Be Saved.
« Reply #477 on: December 06, 2009, 08:31:58 pm »

Wow.
Thanks for the explanation!

I've gotten my save function working, thanks to monkey,
thought there were plenty of changes necessary.

Now I just need to figure out how to load it.
Won't be too bad, but will take some brain hurting.
Logged
[7:53:55 PM] Armok, why did you demand that I don't eat you?
[7:54:34 PM] [Armok]: woooooo

Burried Houses - Platform Explorer Demo H - Cloud Scream

The Mad Engineer

  • Bay Watcher
  • Tock.
    • View Profile
Re: Cloud Scream: > To Be Saved.
« Reply #478 on: December 07, 2009, 04:53:19 pm »

Um... How does one open a 0.23.7z file?

Jack_Bread

  • Bay Watcher
  • 100% FRESH ♥HIPPO♥
    • View Profile
Re: Cloud Scream: > To Be Saved.
« Reply #479 on: December 07, 2009, 04:57:25 pm »

Um... How does one open a 0.23.7z file?
Get 7zip.
Pages: 1 ... 30 31 [32] 33 34 ... 81