Forum

Memory conservation[Bots]

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Memory conservation[Bots]

Postby Mexicouger » Mon Nov 15, 2010 11:16 pm

I was just thinking about making more code efficient, and I thought about some of my personal code, Like red Crosshairs. I put the function in player_pre_think, and it costs about 4 fps[On psp]. So I was just thinking that When bots are in-game, they are thinking about the exact same thing the player is. So when I have a bot in, there is another 4 fps down the drain(just for red crosshairs).

So how about adding another check to The call:

if (cvar("crosshairs") > 1 && self.isuman == TRUE)

That will make it so the bots don't constantly have a traceline, beings that it doesn't matter if they have a red crosshair on their HUD.
That saves memory right there.

This can go for any different kinds of code that Bots don't need to use.

This was just a thought, Please mark me if I am wrong. I like to think aloud.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby Sajt » Mon Nov 15, 2010 11:34 pm

First of all... this isn't conserving "memory", you are reducing CPU load.

Second of all... is "crosshairs" a serverside cvar you have created, like something which can be disabled to improve performance? If so, fine, otherwise, if it's a clientside cvar, you shouldn't be checking it in the server code...

And if you want to improve performance more you could make this traceline occur only every 0.1 seconds or so using a timer field.

if (self.next_crosshair_time < time)
{
do crosshair crap;
self.next_crosshair_time = time + 0.1;
}
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.
Sajt
 
Posts: 1215
Joined: Sat Oct 16, 2004 3:39 am

Postby Mexicouger » Mon Nov 15, 2010 11:48 pm

Sajt wrote:First of all... this isn't conserving "memory", you are reducing CPU load.

Second of all... is "crosshairs" a serverside cvar you have created, like something which can be disabled to improve performance? If so, fine, otherwise, if it's a clientside cvar, you shouldn't be checking it in the server code...

And if you want to improve performance more you could make this traceline occur only every 0.1 seconds or so using a timer field.

if (self.next_crosshair_time < time)
{
do crosshair crap;
self.next_crosshair_time = time + 0.1;
}


I meant Reducing CPU load I suppose. This is kind of a big thing for Psp modders, who might take this into account when adding something. Bots might not need to do what the player does, so make a check for it, and ya might save some CPU speed later down the road. And I meant the command Crosshair. That first check was mainly a little thing, In which I forgot to remove.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby Spike » Tue Nov 16, 2010 12:29 am

a traceline might be slow, but string comparisons are going to be much slower. what I mean by that is that calling 'cvar' 50 times a frame is suicide, if you want a high framerate.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest