Is it possible to use an int in qc?
Moderator: InsideQC Admins
12 posts
• Page 1 of 1
Is it possible to use an int in qc?
Well is it?
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
gnounc wrote:an integer?
like uh...the number 10?
Yes.
I think perhaps I'm confused as to what you're asking exactly.
No, Like this:
- Code: Select all
void() Function =
{
local int i;
//Stuff
};
Or just simply defining an int in Defs.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
Vanilla QuakeC doesn't support integers, only floats.
However, fteqcc and frikqcc does emulate integers (they're still floats internally).
In QuakeC, you can treat a float as a 24 bit integer (ignoring the 8 msb). That's why things like this work:
However, fteqcc and frikqcc does emulate integers (they're still floats internally).
In QuakeC, you can treat a float as a 24 bit integer (ignoring the 8 msb). That's why things like this work:
- Code: Select all
if (self.flags & 1)
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
fteqcc doesn't emulate ints. it has direct support, but uses an extended instruction set.
#define int __integer
#define int float
Take your pick.
Floats are fine for everything you really need. Slightly slower, but its all intepreted anyway. And obviously pointer maths has restrictions with floats. And you're limited to 24 bits instead of 32.
#define int __integer
#define int float
Take your pick.
Floats are fine for everything you really need. Slightly slower, but its all intepreted anyway. And obviously pointer maths has restrictions with floats. And you're limited to 24 bits instead of 32.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
Thanks for the correction, Spike.
Regarding the emulation aspect, I observed that QuakeC indeed runs pretty fast, and even in not so modern hardware is fast enough to turn the idea of writing game logic code in native C worthless (at least, in most of the cases). What really eats a lot of processing resources during QuakeC execution usually are built-ins (traceline is the more frequently used) calling SV_RecursiveHullCheck and other similar function to traverse the BSP tree - which are C code already.
Regarding the emulation aspect, I observed that QuakeC indeed runs pretty fast, and even in not so modern hardware is fast enough to turn the idea of writing game logic code in native C worthless (at least, in most of the cases). What really eats a lot of processing resources during QuakeC execution usually are built-ins (traceline is the more frequently used) calling SV_RecursiveHullCheck and other similar function to traverse the BSP tree - which are C code already.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
I think the game gets weighed down when you spam PlayerPreThink, and PlayerPostThink. I added a cvar function to PlayerPostThink, and the framerate fell by nearly 7 Frames.
Quake c Runs just fine without Ints, So we can go on without them I suppose.
Quake c Runs just fine without Ints, So we can go on without them I suppose.
-

Mexicouger - Posts: 514
- Joined: Sat May 01, 2010 10:12 pm
Mexicouger wrote:I think the game gets weighed down when you spam PlayerPreThink, and PlayerPostThink. I added a cvar function to PlayerPostThink, and the framerate fell by nearly 7 Frames.
Quake c Runs just fine without Ints, So we can go on without them I suppose.
Having ints would be great for bitwise operations: one single int can hold 32 bitflags against 24 in a float.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
Or because it's important NOT HAVING TO create another entity field just because I need 2 or 3 more bitflags in, let's say, .flags ?
Anyway, it's kinda funny see you arguing against the utility of ints in QuakeC, since your engine does support it.
Anyway, it's kinda funny see you arguing against the utility of ints in QuakeC, since your engine does support it.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
The engine requires .flags to be a .float, regardless of whether you can use ints.
I generally prefer to ensure that stuff works with more than one project. it helps figure out what contains the bugs.
ints are faster than floats, yeah, they can be pipelined better than x87 instructions, etc... but at the end of the day, its really not that significant for a game.
I generally prefer to ensure that stuff works with more than one project. it helps figure out what contains the bugs.
ints are faster than floats, yeah, they can be pipelined better than x87 instructions, etc... but at the end of the day, its really not that significant for a game.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
12 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest

