[Help]Saving Halos (in OldCODB)

01/19/2010 00:54 copz1337#1
okay so my plan is to save the Halos (i assume you all know what that is) in OldCODB same as the other things such as, Nobility. Nobility saves the names of people inside the Nobility.dat in OldCODB. So I found out where it sends the info save to OldCODB which is in Database.cs. So I'm trying to make something similar to saving Halos. (so that when you log out it gets saved so that when you re-log you still have it.)

So I'm taking this as an example. But I noticed It's only 1 of these (starting with public static void, sorry if i don't use C# Words lol i'm still learning)
Code:
        }
        public static void SaveKOs()
        {
            FileStream FS = new FileStream(@"C:\OldCODB\KOBoard.dat", FileMode.OpenOrCreate);
            BinaryWriter BW = new BinaryWriter(FS);

            for (int i = 0; i < Game.World.KOBoard.Length; i++)
                Game.World.KOBoard[i].WriteThis(BW);

            BW.Close();
            FS.Close();
        }

And so then I look at the Nobility and then it has SaveEmpire and LoadEmpire. So, I'm assuming that it means that it saves the Nobility rank and then when you login it loads it right? How can I do this for the Halos? (sorry if I've confused you).
Code:
        public static void SaveEmpire()
        {
            FileStream FS = new FileStream(@"C:\OldCODB\Nobility.dat", FileMode.OpenOrCreate);
            BinaryWriter BW = new BinaryWriter(FS);

            for (int i = 0; i < Game.World.EmpireBoard.Length; i++)
                Game.World.EmpireBoard[i].WriteThis(BW);

            BW.Close();
            FS.Close();
        }
        public static void LoadEmpire()
        {
            if (System.IO.File.Exists(@"C:\OldCODB\Nobility.dat"))
            {
                FileStream FS = new FileStream(@"C:\OldCODB\Nobility.dat", FileMode.Open);
                BinaryReader BR = new BinaryReader(FS);

                for (int i = 0; i < Game.World.EmpireBoard.Length; i++)
                    Game.World.EmpireBoard[i].ReadThis(BR);
                BR.Close();
                FS.Close();
            }



#edit- To make things easier, this is what I have to make a "definition" or w\e for right?

Code:
                for (int i = 0; i < Game.World.[B]Halo[/B].Length; i++)
                    Game.World.[B]HaloBoard[/B][i].ReadThis(BR);
This is the one I'm trying to make, I took it as an example for Nobility's SaveEmpire:

Code:
            for (int i = 0; i < Game.World.[B]EmpireBoard[/B].Length; i++)
                Game.World.[B]EmpireBoard[/B][i].WriteThis(BW);
01/19/2010 01:06 pro4never#2
Ok so the database looks approximately right (I've not really done much with I/O from text/dat files but it looks correct)

You will then need something to assign characters their correct halo (look at how nobility is loaded!)

I would think (I don't know) that the easiest way to do it would be: Assign an arbitrary number to each halo for example

1 = top guild
2 = top dep
3 = top troj
etcetcetc

then save/load those values from your .dat file and use the switch statement to control if a player gets a halo or not.. the problem with that is, unless you do some more serious coding, it will only save 1 halo per character (not a problem if you are just doing top class... but still)

You could also have a different database field (separated entries if you are using a .dat format) structured in a way to use 1/0 as true/false to control if a player has a specific halo or not... that would require a bit more string manipulation while loading them and (in my mind any way) may turn out messier but would work just fine.


Anyways back on topic: You need to actually assign the halo to a player when they log in, much like you do with nobility.

Game.World.EmpireBoard[i].ReadThis(BR);

Looks like that is assigning the imported information to some sort of data structure located at Game.World.EmpireBoard. I'd take a peek at how that data is handled through the source and work from there.

Sorry I can't help more. Again, I don't use lotf.
01/19/2010 01:10 copz1337#3
Quote:
Originally Posted by pro4never View Post
Ok so the database looks approximately right (I've not really done much with I/O from text/dat files but it looks correct)

You will then need something to assign characters their correct halo (look at how nobility is loaded!)

I would think (I don't know) that the easiest way to do it would be: Assign an arbitrary number to each halo for example

1 = top guild
2 = top dep
3 = top troj
etcetcetc

then save/load those values from your .dat file and use the switch statement to control if a player gets a halo or not.. the problem with that is, unless you do some more serious coding, it will only save 1 halo per character (not a problem if you are just doing top class... but still)

You could also have a different database field (separated entries if you are using a .dat format) structured in a way to use 1/0 as true/false to control if a player has a specific halo or not... that would require a bit more string manipulation while loading them and (in my mind any way) may turn out messier but would work just fine.


Anyways back on topic: You need to actually assign the halo to a player when they log in, much like you do with nobility.

Game.World.EmpireBoard[i].ReadThis(BR);

Looks like that is assigning the imported information to some sort of data structure located at Game.World.EmpireBoard. I'd take a peek at how that data is handled through the source and work from there.

Sorry I can't help more. Again, I don't use lotf.
Lol I don't think I can pull this off. Might just give up... but I'll have a look. Ty.
01/19/2010 01:21 Korvacs#4
Quote:
Originally Posted by pro4never View Post
then save/load those values from your .dat file and use the switch statement to control if a player gets a halo or not.. the problem with that is, unless you do some more serious coding, it will only save 1 halo per character (not a problem if you are just doing top class... but still)

You could also have a different database field (separated entries if you are using a .dat format) structured in a way to use 1/0 as true/false to control if a player has a specific halo or not... that would require a bit more string manipulation while loading them and (in my mind any way) may turn out messier but would work just fine.
Well, a player can only have one halo active at one time, so that makes things easier. A suggestion i have would be to use a Flag system (similar to player status, bluename/redname/blackname/dead/ghost etc) to determine which halos your entitled too, then the npcs would just need to check if the player has claimed a halo, and to do this you would just need to check the flag.
01/19/2010 02:08 pro4never#5
Quote:
Originally Posted by Korvacs View Post
Well, a player can only have one halo active at one time, so that makes things easier. A suggestion i have would be to use a Flag system (similar to player status, bluename/redname/blackname/dead/ghost etc) to determine which halos your entitled too, then the npcs would just need to check if the player has claimed a halo, and to do this you would just need to check the flag.
But wouldn't non top-class halo be overwritten by other types such as top pk tournament, top guild/dep, etc?

Not a big deal really, just something that I thought could pose a problem if you were doing a simple switch statement.
01/19/2010 02:12 Korvacs#6
Quote:
Originally Posted by pro4never View Post
But wouldn't non top-class halo be overwritten by other types such as top pk tournament, top guild/dep, etc?

Not a big deal really, just something that I thought could pose a problem if you were doing a simple switch statement.
Thats the good thing about Flags, you can have 10 things turned on if you want, you just have to choose which you want, or which get priority over others.

In official conquer you can only store one active halo at a time anyway, so i would create 2 fields, one for flags, and anouther for the active one. So that you can go back to the npcs and switch your halos around if you want to use a different one on a different day.
01/19/2010 02:22 copz1337#7
I definitely won't be able to do this.