Lord FlatHead Posted January 18, 2005 Hello. I've been working on a WAD reader in C, and it just doesn't want to work right. I was hoping some of you programmer guys who have (or have not) worked with the format could tell me what I'm doing wrong. Source code, compiled .exe, test wad and sample output file : http://users.pandora.be/flathead/storage/wadfucker2.zip (25 Kb) As you'll see from the included text file, everything goes fine until about linedef #36 - at that point the buffer I read the linedef information into seems to be filled with random garbage, or most likely nothing at all. Strange thing is, it works fine on small maps (handful of linedefs, 3 or 4 sectors) but whenever I try it on a decent-sized map it does this. I know my little wad file isn't at fault either since I checked in a hex editor. Anyone ? Thanks in advance. 0 Share this post Link to post
Lord FlatHead Posted January 18, 2005 Hacked on it a bit more and now it works perfectly. Guess I panicked a bit too soon. Heh. 0 Share this post Link to post
Gokuma Posted January 18, 2005 To massacre and maim while staying perfectly calm. 0 Share this post Link to post
Lord FlatHead Posted January 18, 2005 My original idea was to read, for example, all the linedefs at once into a buffer using fread(), then going through them one one filling up an array with the values I needed. For some odd reason the buffer got filled with NULL values after a certain point though, so now I just read the records one by one. Seems to work, except I still get a few missing lines now and then. Clicky. 0 Share this post Link to post
Fredrik Posted January 19, 2005 Well, I guess that shows why C++ is crap. 0 Share this post Link to post
Quasar Posted January 19, 2005 Check to make sure your file is opened in binary mode. Opening a file for reading in text mode will cause automatic CRLF translation, and can also interfere with proper fseek behavior. Last time I had a problem with seemingly arbitrary behavior in an IO program, this was the cause of the problem. 0 Share this post Link to post
Darkhaven Posted January 19, 2005 Fredrik said:Well, I guess that shows why C++ is crap. Uh, he said he programmed it in C... So therefore, C is crap too :) 0 Share this post Link to post
Donce Posted January 19, 2005 Lord FlatHead said:wadfucker2.zip Will it f*ck up wads? :) 0 Share this post Link to post
Lord FlatHead Posted January 19, 2005 Darkhaven said:New Map editor or just a reader? Reader. I was thinking of writing a proper renderer and collision code for it too, just as an exercise in C/C++. Fredrik, arguments over which programming language is better than another are the lowest, saddest form of geek discourse :) So let's not. 0 Share this post Link to post
sirjuddington Posted January 19, 2005 Hmm I remember getting those missing lines when I first started playing around with the doom map format. I can't remember what caused it though (reading in text mode caused much bigger errors than that for me). 0 Share this post Link to post
Fredrik Posted January 19, 2005 Darkhaven said:Uh, he said he programmed it in C... So why did he put the code in a .cpp file? Tsk, tsk. Lord FlatHead said:Fredrik, arguments over which programming language is better than another are the lowest, saddest form of geek discourse :)The losing side often employs this argument. 0 Share this post Link to post
Lord FlatHead Posted January 19, 2005 Fredrik said:So why did he put the code in a .cpp file? Tsk, tsk. I didn't, Visual Studio .NET did. 0 Share this post Link to post
Graf Zahl Posted January 19, 2005 Fredrik said:The losing side often employs this argument. But he is right. 0 Share this post Link to post
Fletcher` Posted January 19, 2005 fraggle said:Fredrik is right, dont use C. Lord FlatHead said:just as an exercise in C/C++. 0 Share this post Link to post
Fredrik Posted January 19, 2005 Graf Zahl said:But he is right. Of course not. The lowest, saddest form of geek discourse is editor flamewar. 0 Share this post Link to post
Bucket Posted January 19, 2005 Which reminds me of how many times I've seen people here abuse: 0 Share this post Link to post
Cyb Posted January 19, 2005 Fredrik said:Well, I guess that shows why C++ is crap. I have a wad loader that works perfectly and is written in C++ in fact it's what I use to generate the stats for the Doom wiki :P 0 Share this post Link to post
Darkhaven Posted January 19, 2005 I probably shouldn't have spoken about it anyway, I couldn't download the source / executable before it was removed(?). 0 Share this post Link to post
Sharessa Posted January 21, 2005 WTF, I thought C++ was the standard. Oh well, whatever. All I know is Basic and Python anyway. 0 Share this post Link to post
insertwackynamehere Posted January 21, 2005 Darkhaven said:Uh, he said he programmed it in C... So therefore, C is crap too :) Heh C++ is just an advanced C with classes and stuff (OOP). It's an inside joke to programmers as the "++" operater is like saying "x = x + 1". Therefore "C++" is like saying "C = C + 1" or C++ is better (greater) than C :P However it still wouldnt run. If you wanted a working program it would be:#pragma once #include <iostream> using namespace std; int C = 1; int main() { C++; cout << "C++ is C plus 1! (" << C << ")" << endl; //C++ is C plus 1! (2) return 0; } 0 Share this post Link to post
Lord FlatHead Posted January 21, 2005 Back when I was your age, we had to carve our transistors out of wood. 0 Share this post Link to post
Bloodshedder Posted January 22, 2005 insertwackynamehere said:Once again, thank you Captain Obvious. 0 Share this post Link to post
Doom-Child Posted January 24, 2005 You fools. Real programmers write in machine code they design, because those damn Intel engineers really bogged down the original version. DC 0 Share this post Link to post