|
You last visited: Today at 15:49
Advertisement
GameMap Reading
Discussion on GameMap Reading within the CO2 Private Server forum part of the Conquer Online 2 category.
02/26/2011, 19:06
|
#1
|
elite*gold: 0
Join Date: Dec 2010
Posts: 162
Received Thanks: 31
|
GameMap Reading
Well, I'm having problems reading the decoded GameMap ... It keeps reading the first map , it Doesn't go down...
Code:
IniFile I = new IniFile(ThePath+ @"ini\TheGameMap.txt");
uint TotalMaps = 260;
for (uint i = 0; i < TotalMaps; i++)
{
ushort MapID = I.ReadUInt16("AllMaps", "MapID");
string Path = I.ReadString("AllMaps", "Path");
DMap D = new DMap(MapID, Path);
H_DMaps.Add(MapID, D);
}
and there's an example how the gamemap looks
Quote:
[AllMaps]
MapID=1000
Path=map/map/desert.DMap
PuzzleSize=256// Keeps reading this map.. Doesn't go any further
MapID=1001
Path=map/map/d_antre01.DMap
PuzzleSize=256
MapID=1002
Path=map/map/newplain.DMap
PuzzleSize=256
MapID=1003
Path=map/map/mine01.DMap
PuzzleSize=256
MapID=1004
Path=map/map/forum.DMap
PuzzleSize=256
MapID=1005
Path=map/map/arena.DMap
PuzzleSize=256
MapID=1006
Path=map/map/horse.DMap
PuzzleSize=256
MapID=1100
Path=map/map/star01.DMap
PuzzleSize=256
|
Where am I wrong?
Thank you.
|
|
|
02/26/2011, 20:17
|
#2
|
elite*gold: 0
Join Date: Jan 2008
Posts: 1,434
Received Thanks: 1,147
|
Your structure isn't a valid INI structure. You have the same key a lot of time.
Code:
[Section]
Key=Value
Something like this can work... You can use a loop.
Code:
[Header]
Count=2
[Map0]
MapId=1000
Path=map/map/desert.dmap
PuzzleSize=256
[Map1]
MapId=1000
Path=map/map/desert.dmap
PuzzleSize=256
|
|
|
02/26/2011, 21:27
|
#3
|
elite*gold: 0
Join Date: Dec 2010
Posts: 48
Received Thanks: 6
|
sorry, cant help you im bad in 5165 servers. hope someone els can help you, goodluck
|
|
|
02/26/2011, 22:47
|
#4
|
elite*gold: 0
Join Date: Dec 2010
Posts: 162
Received Thanks: 31
|
Quote:
Originally Posted by CptSky
Your structure isn't a valid INI structure. You have the same key a lot of time.
Code:
[Section]
Key=Value
Something like this can work... You can use a loop.
Code:
[Header]
Count=2
[Map0]
MapId=1000
Path=map/map/desert.dmap
PuzzleSize=256
[Map1]
MapId=1000
Path=map/map/desert.dmap
PuzzleSize=256
|
Yeh Good Idea...
Quote:
Originally Posted by zath
sorry, cant help you im bad in 5165 servers. hope someone els can help you, goodluck
|
You can't code Zath, So Please Don't even TRY to help me.
|
|
|
02/26/2011, 23:41
|
#5
|
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
|
Quote:
Originally Posted by Iron~Man
Yeh Good Idea...
You can't code Zath, So Please Don't even TRY to help me.
|
#Edit;
Why are you trying to make it read from an ini file? o.O
|
|
|
02/27/2011, 09:22
|
#6
|
elite*gold: 0
Join Date: Dec 2010
Posts: 162
Received Thanks: 31
|
Quote:
Originally Posted by Yup Arco
#Edit;
Why are you trying to make it read from an ini file? o.O
|
Because the very original GameMap.dat from the latest client has 2 maps under 1 MapID , so That It gives me error when debugging.
|
|
|
02/27/2011, 12:51
|
#7
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,125
Received Thanks: 2,518
|
Quote:
Originally Posted by Iron~Man
Because the very original GameMap.dat from the latest client has 2 maps under 1 MapID , so That It gives me error when debugging.
|
You just skip one instead of trying to add it to the dictionary.
|
|
|
02/27/2011, 13:11
|
#8
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
This
Code:
H_DMaps.Add(MapID, D);
To
Code:
if (!H_DMaps.Contains(MapID))
H_DMaps.Add(MapID, D);
|
|
|
02/27/2011, 14:18
|
#9
|
elite*gold: 0
Join Date: Dec 2010
Posts: 162
Received Thanks: 31
|
Quote:
Originally Posted by Syst3m_W1z4rd
This
Code:
H_DMaps.Add(MapID, D);
To
Code:
if (!H_DMaps.Contains(MapID))
H_DMaps.Add(MapID, D);
|
Tried that Already, Doesn't work.
|
|
|
02/27/2011, 14:29
|
#10
|
elite*gold: 0
Join Date: Nov 2010
Posts: 1,162
Received Thanks: 370
|
What is the exactly error you're getting?
|
|
|
02/27/2011, 14:36
|
#11
|
elite*gold: 0
Join Date: Dec 2010
Posts: 162
Received Thanks: 31
|
Quote:
Originally Posted by Syst3m_W1z4rd
What is the exactly error you're getting?
|
When I do that, I get no error, It Only Reads The First Map, Then It Stops.
|
|
|
02/27/2011, 16:25
|
#12
|
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
|
Quote:
Originally Posted by Iron~Man
When I do that, I get no error, It Only Reads The First Map, Then It Stops.
|
Why don't you instead, create a program that decodes the gamemap.dat, change the mapid, then encode it again?
#Edit;
Made the program for you, I haven't tested it fully, so there MIGHT be bugs with it, but I tested it a few times and it worked. So try it.
Here's what it does;
It reads the game map.dat and for each map information read(Mapid, Puzzlesize, Path, Pathlength) it creates a new MapInfo(); and saves the map information read, to a new MapInfo();
It then adds the new information to a dictionary, so it can be used later on.
But if the dictionary already holds the information for a certain mapid, then it creates a "randomly" generated map id, then checks if the dictionary already holds that id, if it does hold the new ID, then it generates a new id. Once the program is fully done with that gamemap.dat, it creates a new gamemap.dat file and writes the TotalMaps, then foreach value in the dictionary, it writes the values' information, to the same structure of gamemap.dat.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace GameMap
{
public class MapInfo
{
public uint MapID;
public string Path;
public int PathLength;
public int PuzzleSize;
}
class Program
{
static String Path = @"C:\Users\Arco\Desktop\kkkkk\ini\GameMap.dat";
static Dictionary<uint, MapInfo> Dict = new Dictionary<uint, MapInfo>();
static Random Random = new Random();
static String NewPath = @"C:\Users\Arco\Desktop\GameMap.dat";
static void Main(string[] args)
{
Console.Title = "GameMap.dat";
uint TotalMaps;
using (BinaryReader Reader = new BinaryReader(new FileStream(Path, FileMode.Open)))
{
TotalMaps = Reader.ReadUInt32();
Console.WriteLine("Writing....");
for (int i = 0; i < TotalMaps; i++)
{
uint Mapid = Reader.ReadUInt32();
int Length = Reader.ReadInt32();
string newPath = Encoding.ASCII.GetString(Reader.ReadBytes(Length));
int Puz = Reader.ReadInt32();
MapInfo Map = new MapInfo();
Map.MapID = Mapid;
Map.PathLength = Length;
Map.Path = newPath;
Map.PuzzleSize = Puz;
if (!Dict.ContainsKey(Mapid))
{
Dict.Add(Mapid, Map);
}
else
{
trythis:
uint newMap = (uint)Random.Next(1200, 2000);
if (!Dict.ContainsKey(newMap))
{
Map.MapID = newMap;
Dict.Add(newMap, Map);
Console.WriteLine("The map ID " + Mapid + " was a copy, so it was replaced with the new ID, " + newMap);
}
else
{
goto trythis;
}
}
}
Reader.Close();
}
Console.WriteLine("Done!");
Console.WriteLine("Press enter to begin writing the data to a new GameMap.dat");
Console.ReadLine();
FileStream Fil = new FileStream(NewPath, FileMode.Create);
BinaryWriter BW = new BinaryWriter(Fil);
BW.Write(TotalMaps);
foreach (MapInfo Info in Dict.Values)
{
BW.Write(Info.MapID);
BW.Write(Info.PathLength);
BW.Write(Info.Path);
BW.Write(Info.PuzzleSize);
}
Console.WriteLine("Done!");
Console.WriteLine("Finished writing a new GameMap.dat...");
Console.WriteLine("Press enter to close the program...");
Console.ReadLine();
}
}
}
|
|
|
02/27/2011, 18:47
|
#13
|
elite*gold: 0
Join Date: Dec 2010
Posts: 162
Received Thanks: 31
|
Quote:
Originally Posted by Yup Arco
Why don't you instead, create a program that decodes the gamemap.dat, change the mapid, then encode it again?
#Edit;
Made the program for you, I haven't tested it fully, so there MIGHT be bugs with it, but I tested it a few times and it worked. So try it.
Here's what it does;
It reads the game map.dat and for each map information read(Mapid, Puzzlesize, Path, Pathlength) it creates a new MapInfo(); and saves the map information read, to a new MapInfo();
It then adds the new information to a dictionary, so it can be used later on.
But if the dictionary already holds the information for a certain mapid, then it creates a "randomly" generated map id, then checks if the dictionary already holds that id, if it does hold the new ID, then it generates a new id. Once the program is fully done with that gamemap.dat, it creates a new gamemap.dat file and writes the TotalMaps, then foreach value in the dictionary, it writes the values' information, to the same structure of gamemap.dat.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace GameMap
{
public class MapInfo
{
public uint MapID;
public string Path;
public int PathLength;
public int PuzzleSize;
}
class Program
{
static String Path = @"C:\Users\Arco\Desktop\kkkkk\ini\GameMap.dat";
static Dictionary<uint, MapInfo> Dict = new Dictionary<uint, MapInfo>();
static Random Random = new Random();
static String NewPath = @"C:\Users\Arco\Desktop\GameMap.dat";
static void Main(string[] args)
{
Console.Title = "GameMap.dat";
uint TotalMaps;
using (BinaryReader Reader = new BinaryReader(new FileStream(Path, FileMode.Open)))
{
TotalMaps = Reader.ReadUInt32();
Console.WriteLine("Writing....");
for (int i = 0; i < TotalMaps; i++)
{
uint Mapid = Reader.ReadUInt32();
int Length = Reader.ReadInt32();
string newPath = Encoding.ASCII.GetString(Reader.ReadBytes(Length));
int Puz = Reader.ReadInt32();
MapInfo Map = new MapInfo();
Map.MapID = Mapid;
Map.PathLength = Length;
Map.Path = newPath;
Map.PuzzleSize = Puz;
if (!Dict.ContainsKey(Mapid))
{
Dict.Add(Mapid, Map);
}
else
{
trythis:
uint newMap = (uint)Random.Next(1200, 2000);
if (!Dict.ContainsKey(newMap))
{
Map.MapID = newMap;
Dict.Add(newMap, Map);
Console.WriteLine("The map ID " + Mapid + " was a copy, so it was replaced with the new ID, " + newMap);
}
else
{
goto trythis;
}
}
}
Reader.Close();
}
Console.WriteLine("Done!");
Console.WriteLine("Press enter to begin writing the data to a new GameMap.dat");
Console.ReadLine();
FileStream Fil = new FileStream(NewPath, FileMode.Create);
BinaryWriter BW = new BinaryWriter(Fil);
BW.Write(TotalMaps);
foreach (MapInfo Info in Dict.Values)
{
BW.Write(Info.MapID);
BW.Write(Info.PathLength);
BW.Write(Info.Path);
BW.Write(Info.PuzzleSize);
}
Console.WriteLine("Done!");
Console.WriteLine("Finished writing a new GameMap.dat...");
Console.WriteLine("Press enter to close the program...");
Console.ReadLine();
}
}
}
|
Thankies.
|
|
|
02/28/2011, 10:18
|
#14
|
elite*gold: 0
Join Date: Dec 2010
Posts: 341
Received Thanks: 255
|
Check out my TinyMap release ( )
It reads the GameMap.dat file to load and convert DMaps.
I'm pretty sure I added the source as well, so you can check it out.
|
|
|
|
Similar Threads
|
[Release]GameMap creator/dumper
05/06/2012 - CO2 PServer Guides & Releases - 23 Replies
Well this is the first application I ever made and I decided to share it here and the source is included.
When executed you'll see 2 buttons, Create GameMap.dat and Dump GameMap.dat.
Create GameMap.dat will add a new map to the GameMap.dat (specified in the config.ini)
Dump GameMap.dat will dump a list of map names/IDs/sizes in a text file.
The config file:
|
[MiniRelease] Make new GameMap.dat work with Korv's DmapHandler
02/16/2012 - CO2 PServer Guides & Releases - 6 Replies
Ok so for those who don't know...
GameMap.dat in new clients refers to the new packed dmaps that tq uses (.7z). This poses an issue for those wanting to use Korv's dmap handler for their server/bot/etc. It will give all sorts of errors because it is trying to read .7z files as though they were still .DMaps.
This simple program edits your GameMap.dat file to change extensions back to .dmaps.
TO USE
Select all .7z files in the map folder and extract them. Winrar does this without...
|
Decoding GameMap.dat
09/21/2010 - CO2 Programming - 15 Replies
Well I was working on a project tonite, it was decoding Gamemap.dat.
Thanks to the help of haydz I finally got this and it works!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
|
tnx 4 reading dis
07/15/2008 - Cabal Online - 6 Replies
the past versions(1.05 and 1.06) is not working on my pc as well as this new version(1.07). the control panel do not pop up when my char has logged in on to the game. i did turned my firewall off and my deepfreeze. i also checked files as well and updated GG before starting CR
i tried to download it on a shop and it worked 100%!
can someone explain me this?
i'm using windows xp
@badburn
tol tga bacoor ako sa camella springville
here's my YM:
|
All times are GMT +2. The time now is 15:49.
|
|