[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4787: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4789: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4790: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4791: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3922)
InsideQC Forums • View topic - Game code in C

Game code in C

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Game code in C

Postby JasonX » Fri Mar 11, 2016 3:57 am

I'm working on my engine port and i've decided to drop QuakeC altogether and use pure C, or even an external DLL in the future, for the game code. Does anyone know where to start on this? I mean, just the basics like the ScratchQC project: loading a map and putting a camera there. What are the functions that QuakeC itself calls?
JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: Game code in C

Postby Baker » Fri Mar 11, 2016 2:47 pm

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Game code in C

Postby JasonX » Fri Mar 11, 2016 8:05 pm

JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: Game code in C

Postby Baker » Fri Mar 11, 2016 8:12 pm

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Game code in C

Postby JasonX » Fri Mar 11, 2016 9:12 pm

Another question: inside SV_TouchLinks, the following is called: PR_ExecuteProgram(touch->v.touch). What is this for? There are some other calls to PR_ExecuteProgram that don't seem to be functions...
JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: Game code in C

Postby Baker » Fri Mar 11, 2016 10:44 pm

Load map dm6

Type "edicts" in the console

Look at edict #8

You can just type "edict 8" in the console to see just edict #8. One of the fields you will see is "touch" ... and that specific entity has something in that field.

(I mean I could answer the question directly, but it is better if you use the edict command and directly view what is going on. Doing the above will give you about everything you need to know on handling that. You'll need to use that "edict" command a lot with what you are doing.)
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Game code in C

Postby JasonX » Sat Mar 12, 2016 7:41 pm

JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: Game code in C

Postby Spike » Sat Mar 12, 2016 8:52 pm

pr_strings is just an offset into the qc string table. if you're serious about running C code, just treat it as ((char*)NULL) and remove it when practical.
you just need to look out for dereferences, which are safe in qc as they're effectively just empty strings.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Game code in C

Postby r00k » Mon Mar 14, 2016 8:06 am

Something else you can do, for learning purpose, is to look at the KTX gamecode source in C. It's for QuakeWorld but then, that shouldn't matter.

https://github.com/deurk/ktx
r00k
 
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: Game code in C

Postby JasonX » Mon Mar 14, 2016 5:50 pm

Thanks a lot for the info, guys. However, by removing the indexed calls and leaving just the char*, i still get protocol errors: Host_Error: CL_ParseServerMessage: Server is protocol 66820 instead of 15
JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: Game code in C

Postby Baker » Mon Mar 14, 2016 7:11 pm

The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: Game code in C

Postby frag.machine » Mon Mar 14, 2016 8:39 pm

I'd suggest you to have a small function or even a macro that receives the value corresponding to the string offset and returns a proper char * and use it every time a string is referred in the code. This should fix most (if not all) problems due invalid string references. Actually, forget what I said: IIRC such macros already exist in pr_builtins.c. Just use it (you may need to move it to quakedef.h tho)

Also, if you are really set with the idea of pure C for game logic maybe the Quake 2 engine would be a good reference.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2120
Joined: Sat Nov 25, 2006 1:49 pm

Re: Game code in C

Postby Spike » Mon Mar 14, 2016 11:26 pm

set cl_shownet 2
see where your server differs from the version you started with.
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Game code in C

Postby JasonX » Wed Mar 16, 2016 4:15 pm

I'm a little bit lost on how the pr_strings thing works. By default, when a server is started, anything read from *.bsp is parsed into the PR_* structures and then sent along as integers over the network? Should i just use chars instead?
JasonX
 
Posts: 422
Joined: Tue Apr 21, 2009 2:08 pm

Re: Game code in C

Postby frag.machine » Wed Mar 16, 2016 7:31 pm

pr_strings is a pool of immutable strings (ex: "You got the ", " left the game with ", "progs/player.mdl", etc), previously declared in QuakeC code and stored at the begin of the progs.dat file, concatenated with a '\0' char as separator between individual strings and "\0\0" as final marker. When the engine loads the progs.dat it reads this chunk of text into pr_strings. Every string reference in QuakeC is actually an integer offset to this pool, and every time you need the actual string (ex: when the QuakeC interpreter executes a bprint() call) the macros at pr_builtins.c I mentioned before returns a char pointer to this pool.

Note that this applies only to immutable strings. Strings built during runtime (ex: ftos()) are stored in pr_str_tmp (or something named like that, can't remember right now).

Regarding the error you are facing: most likely you are not sending correct string values. Specially in the case of the precache lists, which are read exactly from pr_strings. Maybe my explanation above will make things a bit easier to debug now.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2120
Joined: Sat Nov 25, 2006 1:49 pm

Next

Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests