How to get data from game into a text file or database


#1

Hello, I need to get data about bots in the game from the game into something readable be another program. Does anyone know any easy way to do this? I thought it’d be easy even for a novice C programmer but I’ve just discovered that you can’t use standard libraries and then compile the game. If you think that there’s no clever way of doing this then please say so, It’d be useful to know that this is a pointless endeavour, or one that requires skills that I lack.


#2

The game appears to be compiled against the standard C libraries. For example, see https://github.com/ioquake/ioq3/blob/master/code/client/cl_main.c#L544

The question of where to do the writing from is more complicated, that depends on exacly what you want to store.


#3

my understanding is that you can’t use any of the standard c libraries, idk what’s going on in that file: http://wiki.ioquake3.org/Getting_the_most_from_Quake3_C . I’ve also tried compiling the game with nothing changed in the code apart from adding ‘#include <stdio.h>’ in ‘ai_main.c’, and that leads to the compiler returning an error


#4

Sorry, it’s been ages since I messed with this stuff :slight_smile:

So there are two different kinds of C code in the source tree: there’s the engine and tools code which is compiled into normal native binaries and there’s the “game/mission pack” code that is compiled into… something. I’m not entirely clear on this because it looks like there are object modules (.o files) from these that seem to be just plain native object modules but also .asm files that are most definitely not normal x86 assembly. In any case, the engine code gets to use the standard library, it looks like the game code does not.

Since it sounds like you want information from the bots, if there are no functions to do arbitrary file IO available to the game code, I expect you’d have to provide a way to do so that is accessible from the VM (it looks like this can be done through the “syscall” interface). However, that wouldn’t be portable: you couldn’t just run it on anyone’s client/server, it would have to be run on your modified client/server.

But I think the easiest thing to do may be to use Com_Printf() or something like that to write a specially formatted message to the console and logfile. Then parse those messages out from the program where you’re trying to capture the data. It’s not pretty, but it gets the job done.


#5

what exactly is the logfile called? I’m new to this, when I searched through my ioq3 directory after playing a ctf game couldn’t find any informative readable files that had ‘log’ in the name. Is there any reason this wouldn’t work if standalone assets (ie openarena assets) are used?


#6

It looks like logfiles get stored in your $HOME/.q3a/baseg3 directory, at least for the normal game. For mods they might be under mod subdirectories in $HOME/.q3a.

There’s a cvar that controls the logfile name, “g_log”. Setting this created a new logfile for me.


#7

that works but the log goes straight to the mingw console? any way around this? -well to be more specific, using /logfile returns ‘log file opened’ and it’s showing ‘xxx died to xxx’ in the mingw terminal, i assume that’s what the logs are mean to do lol. Even if you can’t help, thanks for trying!


#8

i found where the logfiles are, it’s not just sticking everything in the mingw terminal as far as i can tell… it was in ‘C:\Users\Dominic\AppData\Roaming\Quake3\baseoa’. Thanks for taking the time to help


#9

Cool, I wasn’t sure where the .q3a directory mapped to under Windows. But that makes sense. It sounds like $HOME/.q3a -> C:\Users<your-id>\AppData\Roaming\Quake3 on Windows.

Anyway, glad to hear it worked out!


#10

The wiki has some tips for getting to that directory quickly, and similar locations on every platform: http://wiki.ioquake3.org/Players_Guide#Where_are_my_files.3F_I.27m_used_to_them_being_in_the_Quake_3_directory.21


#11

should com_printf go to the console? are there any rules about where/how it can be used? I try printing from ai_main.c and the logfile certainly doesn’t have anything that I wanted it to print in


#12

Use G_LogPrintf() to print to the games.log file.


#13

is there a reason that these might not work with a mod enabled? Or any mistakes you think I might be making? I’m trying to do this with openarena files and I’ve seen no sign of any of the various print functions that i’m putting into the code working


#14

Use which vm/qagame.qvm console command to check if ioq3 is using your mod code or mod from in a pk3.


#15

i literally realised that jsut as you posted lol


#16

well, i realised that it might be using the wrong code… thanks

after ages of doing it wrong and using gamefiles I hadn’t edited, I’ve finally got it working on a linux vm- thanks