[streams] Problem beim einlesen von Struktur
			Online-tutorials.net Forenübersicht/C++ / C#/[streams] Problem beim einlesen von Struktur
			Antworten Neues Thema Bottom Seite 1  
| Autor | |
	Nachricht      nächster / vorheriger Thread | 
| SimonOnline-tutorials.net Administrator
 
 
  
 Registriert seit: 01.1970
 Wohnort:Dornbirn
 Beiträge:1181
 
 | [streams] Problem beim einlesen vonHi,
 
 ich schreibe gerade ein kleines Tutorial das zeigt wie man einen einfachen Leveleditor macht, und jetzt benutze ich Streams um die Daten zu speichern, leider klappt das nicht so ganz wie ich es will.
 
 In die Datei schreibt er sowas wie 0047E7B0, wenn er sie ausliest kommt danach aber bei Test.iMapID 926167088 anstelle von 36.
 
 level.cpp
 
 
 Code:
 
 #include "Level.h"
 
 using namespace bn;
 
 LevelData LevelInfo;
 
 Level Lvl;
 
 int main()
 {
 LevelInfo.iMapID = 36;
 
 Lvl.Init(&LevelInfo);
 Lvl.SaveLvl("test.drg");
 
 LevelInfo.iMapID = 4;
 
 Lvl.LoadLvl("test.drg");
 
 //   cout iMapID;
 return 0;
 }
 
 
 level.h
 
 Code:
 
 //Include files
 #include
 #include
 #include
 
 using namespace std;
 
 namespace bn
 {
 //Saves the stuff
 struct LevelData
 {
 unsigned int iMapID;
 unsigned int iChipSetID;
 unsigned int iWidth;
 unsigned int iHeight;
 };
 
 //Saves the informations if its a teleport field
 struct TeleportField
 {
 int iMapID;
 int iTargetWidth;
 int iTargetHeight;
 };
 
 //Saves the field informations
 struct MapField
 {
 string   strBitmapName;
 int      iWidth;
 int      iHeight;
 TeleportField Teleport;
 };
 
 
 //This class manages the 2D Levels
 class Level
 {
 public:
 
 //Initialize the class
 void Init(LevelData *pLevelData)
 {
 pLevelDatas = pLevelData;
 }
 
 //Destructor
 ~Level(){}
 
 //Saves the level
 void SaveLvl(char *pFilename)
 {
 fstream fStream;
 
 //Opens the file binary
 fStream.open(pFilename,fstream::out | fstream::binary);
 
 //Writes the LevelData
 fStream > (char*)&Test;
 
 cout
 -------------------
                         http://www.online-tutorials.net/wiki/funktionsname
 Für was Personal Firewalls GnuGP emails verschlüsseln C++ Tutorial Sicherheits Tutorials
 
 
 
 
 
 | 
| 28.08.2004 15:00 | Homepage >>  >>Profil >> Zitat >> IP gespeichert | 
| Keywords:C++, streams, tutorial, leveleditor, ifstream | 
|---|
| SimonOnline-tutorials.net Administrator
 
 
  
 Registriert seit: 01.1970
 Wohnort:Dornbirn
 Beiträge:1181
 
 | fStream.write((char*)pLevelDatas,sizeof(*pLevelDatas);
 ifStream.read((char*)&Test,sizeof(Test));
 
 hat das Problem beseitigt!
 -------------------
                         http://www.online-tutorials.net/wiki/funktionsname
 Für was Personal Firewalls GnuGP emails verschlüsseln C++ Tutorial Sicherheits Tutorials
 
 
 Firefox - besser durch das Web! 
 
 | 
| 28.08.2004 15:22 | Homepage >>  >>Profil >> Zitat >> IP gespeichert | 
|  | nächster / vorheriger Thread | 
Antworten Neues Thema Top Seite 1