Pages: [1]
  Print  
Author Topic: Source for program that converts Quake1 to Quake3/OA format - GPLv2  (Read 6960 times)
Mirakus
Nub


Cakes 0
Posts: 8


« on: April 21, 2011, 07:20:18 PM »

Here is the source for a small program I wrote which converts maps from Quake 1 to Quake3/OA/etc.  Basically all that it does is add three 0's to each surface of a brush in the map file, so that Radiant will recognize it as an OA/Q3 map. 

I'm sure there are plenty of scripts/programs that already accomplish this, but I was having a very hard time finding anything, and made the decision to just write some code to do it.  You will still need to handle the other parts of fully converting a map (entities, textures) yourself. 

I've only tested this on my GNU/Linux system, but it should build fine under Windows since all it uses is stuff in the C++ standard.  I would imagine you should have no problem building it with MinGW or creating a project for it under visual studio, but if doing the latter, you will want to make sure you're building it as a console application and run it from the command line. 

Usage: quakeconv infile outfile

Where infile is the original Quake map you wish to convert, and outfile is the resultant Q3/OA map.  This is something I whipped up quickly for a specific purpose, so there might be some bugs, but all of the maps I've converted have built fine.  Also, I was working on a way to convert the Q3 format back to Quake, that way I could make some interesting single player levels, but never got that far and wanted to get this out there.  I truly hope it's useful!

Also, I've renamed the filename extension to .c, but it is c++ code, make sure you rename the file/build accordingly. 
Logged
fromhell
Administrator
GET A LIFE!
**********

Cakes 35
Posts: 14517



WWW
« Reply #1 on: April 21, 2011, 07:56:03 PM »

Does it handle the teleporters and adapts the 'pushes' too?

Hopefully i'll be able to use this, as I prototype my maps through Quake first  (oa_bases7 was qrototyped)
Logged

asking when OA3 will be done won't get OA3 done.
Progress of OA3 currently occurs behind closed doors alone

I do not provide technical support either.

new code development on github
Mirakus
Nub


Cakes 0
Posts: 8


« Reply #2 on: April 21, 2011, 08:46:17 PM »

I did have to set a target for one of my teleporters again, but I think that's just because I made some other mistake.  Also, doors, platforms, and switches continued to work.  I was also able to keep my lighting!  I think most of the stuff between the two engines is compatible aside from things like weapons and items.  Honestly, I just haven't tried it on enough maps yet.  I converted a few of the ones I did for Q1 as well as some of the source maps for Quake 1...other than the texturing, most everything seemed to be okay. 
Logged
Gig
In the year 3000
***

Cakes 45
Posts: 4378


WWW
« Reply #3 on: April 22, 2011, 12:47:41 AM »

Realeasing an executable version could be a nice thing...
Logged

I never want to be aggressive, offensive or ironic with my posts. If you find something offending in my posts, read them again searching for a different mood there. If you still see something bad with them, please ask me infos. I can be wrong at times, but I never want to upset anyone.
Graion Dilach
Member


Cakes 12
Posts: 403



« Reply #4 on: April 22, 2011, 06:20:04 AM »

It's nice. Even if I somehow miscompiled it in MSVC2008. I get a file filled with 0Ahs from every maps I tried. Crap that I messed up Dev-Cpp with installing MinGW. That was the only thing which compiled what I wrote without a problem.
Logged

One shall remind what have he left behind... to actually realize that it's still cool.
7
Member


Cakes 7
Posts: 278


Is 7 up?


« Reply #5 on: April 22, 2011, 08:28:07 AM »

If I understand correctly the only thing the code has to do is to append three zeroes to every line that starts with a bracket? If so then the simplest way to implement it is to write a standard i/o filter:

Code:
#include <iostream>
#include <string>

int main()
{
std::string line;
while(std::getline(std::cin, line)) {
std::cout << line;
if('(' == line[0]) {
std::cout << " 0 0 0";
}
std::cout << '\n';
}
return 0;
}

Usage: quakeconv < infile > outfile
Logged

I'm on the ten most wanted list, I've got it dead in the groove.
My face is on every wanted poster in town, for the way I move.
Mirakus
Nub


Cakes 0
Posts: 8


« Reply #6 on: April 22, 2011, 10:05:18 PM »

Well, I have found one oddity that I can't explain yet.  In the two maps I originally did for Quake, there are a couple of select groupings of brushes that will not draw, yet they're shown with a proper texture in Radiant.  It hasn't caused any serious side effects though other than brief blur in one area of the map I've been working on.  I'll have to look through the map file and see if I can pick out anything obvious.  Also, remember that the program creates a new copy of the map and doesn't trash your source one unless you specify infile and outfile as the same on the command line. 

I'm sure there are plenty of other (and easier) ways to implement this, but I kind of took a "hack my way to getting it to work" approach.  I'm just glad I could get something working!   Cheesy
Logged
7
Member


Cakes 7
Posts: 278


Is 7 up?


« Reply #7 on: April 23, 2011, 01:00:48 AM »

Hey I'm not trying to put you down, I just wanted to demonstrate you don't need to read every line of the file into an array before you start changing them. You only have to do that if there are so called forward references in the file, that's when you don't know how to change a line until after you've read  and parsed more lines (for example if you only know how to change line 10 after reading line 300).

Even with forward references it's not really necessary to put all lines in an array, another approach is to read and parse the file twice: the first time to do all the work you can and to keep note of any forward references that come up, and a second time to fill in all the missing references. (This is why most compilers read your source files more than once by the way, every time a compiler reads your source files to resolve more forward references is called a parser pass.)

Edit:
Messed up the terminology, it's forward references.
« Last Edit: April 23, 2011, 02:30:57 AM by 7 » Logged

I'm on the ten most wanted list, I've got it dead in the groove.
My face is on every wanted poster in town, for the way I move.
Peter Silie
Member


Cakes 2008
Posts: 610



« Reply #8 on: April 23, 2011, 05:59:59 AM »

parsing?
sounds like to be a job for sed Smiley
Logged
andrewj
Member


Cakes 24
Posts: 581



« Reply #9 on: April 23, 2011, 06:41:36 AM »

sed -e "g/^[(]/s/$/ 0 0 0/"
Logged
Mirakus
Nub


Cakes 0
Posts: 8


« Reply #10 on: April 23, 2011, 05:10:38 PM »

7, on the contrary, I'm very happy for the suggestions.  I haven't really coded anything for a while, and pretty much just thought of one possible solution and went with it.  I haven't quite bent my around your suggestion with the i/o filter, but I'll play around with it next time I go back to the program.  Thanks!  Thanks also for the sed suggestion.  I've been using linux systems for a few years now, but never quite learned how to use it. 
Logged
Peter Silie
Member


Cakes 2008
Posts: 610



« Reply #11 on: April 23, 2011, 05:39:29 PM »

the streaming editor is a mighty tool as you can see on andrews solution for your problem. Smiley
anyway: you always can solve a problem in different ways and if you do it for fun, all solutions are welcome!
maybe there is also a solution in brainforget or whatever - curious about that Grin

[EDIT]: cmon lei lol: this is the name of a programing language! Cheesy
Logged
Pages: [1]
  Print  
 
Jump to: