mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-25 05:11:05 +00:00
Client: Make Point Updating considerably more efficient.
Stop iterating over the large array all of the time, it's stupid :^)
This commit is contained in:
parent
82d66c5cf5
commit
4cf879558f
1 changed files with 17 additions and 1 deletions
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
HUD Drawing Code
|
HUD Drawing Code
|
||||||
|
|
||||||
Copyright (C) 2021 NZ:P Team
|
Copyright (C) 2021-2022 NZ:P Team
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU General Public License
|
modify it under the terms of the GNU General Public License
|
||||||
|
@ -179,6 +179,8 @@ void() HUD_AmmoString =
|
||||||
#define MAX_POINT_ELEMENTS 64 // the maximum amount of point differential elements that can be spawned before
|
#define MAX_POINT_ELEMENTS 64 // the maximum amount of point differential elements that can be spawned before
|
||||||
// we iterate back from 0
|
// we iterate back from 0
|
||||||
|
|
||||||
|
float active_point_elements;
|
||||||
|
|
||||||
var struct
|
var struct
|
||||||
{
|
{
|
||||||
float difference; // the difference of points
|
float difference; // the difference of points
|
||||||
|
@ -188,6 +190,7 @@ var struct
|
||||||
float y_velocity; // how fast the element moves on the y axis
|
float y_velocity; // how fast the element moves on the y axis
|
||||||
float opacity; // the opacity of the text_string as it progresses
|
float opacity; // the opacity of the text_string as it progresses
|
||||||
float string_width; // the width of text_string
|
float string_width; // the width of text_string
|
||||||
|
float occupied; // is this array being used/occupied?
|
||||||
string text_string; // either '+(difference)' or '-(difference)'
|
string text_string; // either '+(difference)' or '-(difference)'
|
||||||
} point_elements[MAX_POINT_ELEMENTS];
|
} point_elements[MAX_POINT_ELEMENTS];
|
||||||
|
|
||||||
|
@ -237,15 +240,28 @@ void(float amount) RegisterPointChange =
|
||||||
// start with an opacity of 1
|
// start with an opacity of 1
|
||||||
point_elements[index].opacity = 1;
|
point_elements[index].opacity = 1;
|
||||||
|
|
||||||
|
// the element is being used
|
||||||
|
point_elements[index].occupied = true;
|
||||||
|
|
||||||
// iterate
|
// iterate
|
||||||
last_point_element_index++;
|
last_point_element_index++;
|
||||||
|
active_point_elements++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void(float pwidth, float width, float height) PointUpdate =
|
void(float pwidth, float width, float height) PointUpdate =
|
||||||
{
|
{
|
||||||
|
if (active_point_elements == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
vector POINT_DIFF_COLOR;
|
vector POINT_DIFF_COLOR;
|
||||||
|
|
||||||
for (float i = 0; i < MAX_POINT_ELEMENTS; i++) {
|
for (float i = 0; i < MAX_POINT_ELEMENTS; i++) {
|
||||||
|
if (point_elements[i].opacity <= 0 && point_elements[i].occupied == true) {
|
||||||
|
point_elements[i].occupied = false;
|
||||||
|
active_point_elements--;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// should the text be red or orange?
|
// should the text be red or orange?
|
||||||
if (point_elements[i].difference > 0) {
|
if (point_elements[i].difference > 0) {
|
||||||
POINT_DIFF_COLOR = TEXT_ORANGE;
|
POINT_DIFF_COLOR = TEXT_ORANGE;
|
||||||
|
|
Loading…
Reference in a new issue