[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/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 - arrays in quake?

arrays in quake?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

arrays in quake?

Postby ceriux » Wed Jan 25, 2012 8:12 pm

User avatar
ceriux
 
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: arrays in quake?

Postby Cobalt » Thu Jan 26, 2012 1:22 am

Good questions. BTW, what would be an example useage for arrays in QC?
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: arrays in quake?

Postby ceriux » Thu Jan 26, 2012 3:11 am

User avatar
ceriux
 
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: arrays in quake?

Postby Baker » Thu Jan 26, 2012 4:15 am

Last edited by Baker on Thu Jan 26, 2012 4:17 am, edited 1 time in total.
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: arrays in quake?

Postby Arkage » Thu Jan 26, 2012 4:17 am

Can't you test then and see?

I remember reading something about having to wrap them in round brackets in FTEQCC.
User avatar
Arkage
 
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm

Re: arrays in quake?

Postby OneManClan » Thu Jan 26, 2012 4:34 am

OneManClan
 
Posts: 247
Joined: Sat Feb 28, 2009 2:38 pm

Re: arrays in quake?

Postby Jukki » Thu Jan 26, 2012 5:19 am

Yes it worked. But it didnt do so well with huge functions and stuff like that.
Jukki
 
Posts: 214
Joined: Wed Apr 07, 2010 4:59 am

Re: arrays in quake?

Postby Spike » Thu Jan 26, 2012 10:15 am

with fteqcc:
.float foo[64];
defines a field array with 64 elements.

self.foo[y] = 5;
sets element 'y' in that array to 5.

As Arkage said, older versions of fteqcc require extra brackets for field arrays: self.(foo[y]) = 5; (which kinda illustrates how fields work internally). The current version doesn't need that, but does accepts the extra brackets if you want to be paranoid.

FTEQCC's arrays are single-dimension only, thus you need to do: [x+y*width] to get 2d functionality.
As Baker said, remember that this creates 64 fields and will increase your entity size and memory footprint by quite a bit, so if you're on an embedded system you may need to be more cautious.

If you're not using any opcode extensions (ie: no -TFTE) then both reading and writing arrays will be emulated with a function call, containing a binary search to get the element, which can be somewhat slow to access.
This means that you cannot define arrays inside another function (you also cannot pass an array from one function to another).
.
Spike
 
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: arrays in quake?

Postby r00k » Thu Jan 26, 2012 5:07 pm

r00k
 
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: arrays in quake?

Postby Cobalt » Thu Jan 26, 2012 7:05 pm

Good example !

Darn, Darkplaces dont like : entity dm_spawns [16];

guess it wont work for an idea I had.


[quote="r00k"]example
[code]
User avatar
Cobalt
 
Posts: 445
Joined: Wed Jun 10, 2009 2:58 am
Location: New England, USA

Re: arrays in quake?

Postby ceriux » Fri Jan 27, 2012 7:48 am

so if i were to use arrays to define stats and inventory it would mean in a multiplayer game since all entities share these fields that each player would carry the same items and have the same stats? if so it seem's arrays would be okay for single player, but what if i wanted to do multiplayer ? how does prydon do these things?
User avatar
ceriux
 
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: arrays in quake?

Postby Baker » Fri Jan 27, 2012 8:09 am

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: arrays in quake?

Postby Arkage » Fri Jan 27, 2012 6:20 pm

User avatar
Arkage
 
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm

Re: arrays in quake?

Postby ceriux » Fri Jan 27, 2012 7:39 pm

right, but you can't really define player1,player2. it's simply player. unless the engine would handle the difference between players?

baker: so this is how darkplaces would use arrays? e.inv_6_4 = val;
User avatar
ceriux
 
Posts: 2230
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Re: arrays in quake?

Postby Arkage » Fri Jan 27, 2012 8:47 pm

I just used player1 and 2 as an example. All players are entity's and so every entity has that .herp array. You just have to find the entity for that player.
Unless I misunderstood what you meant?
User avatar
Arkage
 
Posts: 66
Joined: Thu Nov 19, 2009 4:17 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 2 guests