PDA

View Full Version : COLOR HELP



azncrip4lif
07-06-2002, 01:09 AM
I wrote a color script to change parts of tha game with my opengl but im having problems compiling i keep getting

C:\hudintercept\color.cpp(154) : error C2146: syntax error : missing ';' before identifier 'thelogo'
C:\hudintercept\color.cpp(154) : fatal error C1004: unexpected end of file found
what do i do?

Deiussum
07-06-2002, 04:36 AM
It might be helpful if you would post a bit of code. Especially line 154 of color.cpp.

All I can say about your error is that you are possibly trying to instantiate some variable thelogo with a type that hasn't been defined yet. Could be a typo on your part, could be a missing header, could be a missing semi-colon somewhere before that line, could be any number of other things.

azncrip4lif
07-09-2002, 10:30 PM
this is a script from a part of my project





#include "stringfinder.h"
#include <vector>


typedef unsigned long DWORD;
#include "color.h"

// Color Manager
ColorManager colorList;


//================================================== ======================================
void ColorManager::init()
{
indexes.clear();
list.clear();
insertpos = 0;

// identifer R G B A Access Index
add("cross" ,255,255,255,200 ); // index: 0
add("team1" ,255, 40, 40 ); // index: 1
add("team2" , 40, 80,255 ); // index: 2
add("special" ,155,155,155 ); // index: 3
add("target" ,102,204, 51 ); // index: 4
add("hud" ,120,120,255 ); // index: 5
add("sound" , 68, 68,255 ); // index: 6
add("bombtimer" ,255, 40, 40 ); // index: 7
add("systime" ,255,255,255 ); // index: 8
add("esp" ,255,255, 0 ); // index: 9
add("back" , 0, 0, 0, 128 ); // index:10
add("radar1" , 80,150, 30, 110 ); // index:11
add("radar2" ,150,150,150, 60 ); // index:12
add("text" , 50,100,255 ); // index:13
add("wire" ,255,255, 0 ); // index:14
add("lambert" ,255,255,255 ); // index:15
add("death" ,255, 0, 0 ); // index:16
add("con_back" , 10, 10, 30, 128 ); // index:17
add("con_text" ,255,255, 30 ); // index:18
add("con_text2" ,160,160,222, 128 ); // index:19
add("con_edit" ,255,255,255 ); // index:20
add("menu_back" , 10, 10, 30, 128 ); // index:21
add("menu_select",150, 70, 10, 128 ); // index:22
add("menu_text" ,255,255,255 ); // index:23
add("text_back" , 0, 0, 0, 128 ); // index:24
add("snake_back" , 0, 0, 0, 128 ); // index:25
add("snake_body" , 0,200, 66, 200 ); // index:26
add("snake_item" , 0, 55,222, 200 ); // index:27
add("snake_wall" ,222, 66, 22, 200 ); // index:28
add("tlight" ,222,111,111, 255 ); // index:29
add("snd_step" ,255,255,255, 255 ); // index:30
add("snd_weapon" ,144,155,255, 255 ); // index:31
add("snd_hit" ,222,100, 61, 254 ); // index:32
add("snd_special",222,111,111, 254 ); // index:33
add("snd_default",222,255,222, 255 ); // index:34
add("team3" ,200,200, 0 ); // index:35
add("team4" , 20,222,100 ); // index:36
add("nade" ,100,255,160 ); // index:37
add("treload" ,255,128, 0 ); // index:38
add("ctreload" , 64,144,255 ); // index:39
add("lamer" ,165, 0,165 ); // index:40
add("lamer-lock" ,222, 0,222 ); // index:41
add("tsound" ,255,144,144 ); // index:42
add("ctsound" ,144,144,255 ); // index:43
add("meterone" ,255,0 , 0 ); // index:44
add("metertwo" ,255,128, 0 ); // index:45
add("meterthree" ,255,255, 0 ); // index:46
add("meterfour" ,128,255, 0 ); // index:47
add("meterfive" ,0 ,255, 0 ); // index:48
add("deadt" , 64, 0, 0 ); // index:49
add("deadct" , 0, 0, 64 ); // index:50


}

//================================================== ======================================
void ColorEntry::fill_missing()
{
compiled = (r<<24) + (g<<16) + (b<<8) + a;
fr= float(r)/255.0f/30.0f;
fg= float(g)/255.0f/30.0f;
fb= float(b)/255.0f/30.0f;

onebased_r=float(r)/255.0f;
onebased_g=float(g)/255.0f;
onebased_b=float(b)/255.0f;
onebased_a=float(a)/255.0f;
}

//================================================== ======================================
void ColorManager::add(const char* name,int r, int g, int b, int a)
{
indexes.add(name,insertpos);

ColorEntry tmp;
tmp.r=r;
tmp.g=g;
tmp.b=b;
tmp.a=a;
tmp.fill_missing();

list.push_back(tmp);

insertpos++;
}
#define BOUND_INTEGER(var,min,max) if((var)>(max)){(var)=(max);};if((var)<(min)){(var)=(min);}


//================================================== ======================================
void ColorManager::set(char* name, char* red, char* green, char* blue, char* alpha)
{
if( !indexes.find(name) ){ return; }

int index = indexes.num;
char format[]="%d";

ColorEntry tmp;
sscanf(red ,format,&amp;tmp.r);
sscanf(green ,format,&amp;tmp.g);
sscanf(blue ,format,&amp;tmp.b);
sscanf(alpha ,format,&amp;tmp.a);

tmp.fill_missing();

BOUND_INTEGER(index,0,int(list.size()-1));
list[index] = tmp;
}


static HSPRITE thelogo = SPR_Load("sprites/thelogo.spr");
SPR_Set(thelogo,255,255,255);
int hleft = frame_h;
wrect_t r;
r.left = 0;
r.right = 200;
r.bottom = 256;
int mod = 0;
if(cvarx.menuback==2)
mod = 3;
if(hleft>=256)
{
hleft -= 256;
r.top = 0;
SPR_Draw(mod+0,x,frame_y+hleft,&amp;r);
}
else if(hleft>0)
{
r.top = 256 - hleft;
hleft = 0;
SPR_Draw(mod+0,x,frame_y+hleft,&amp;r);

}
if(hleft>=256)
{
hleft -= 256;
r.top = 0;
SPR_Draw(mod+1,x,frame_y+hleft,&amp;r);
}
else if(hleft>0)
{
r.top = 256 - hleft;
hleft = 0;
SPR_Draw(mod+1,x,frame_y+hleft,&amp;r);
}

if(hleft>0)
{
r.top = 256 - hleft;
hleft = 0;
SPR_Draw(mod+2,x,frame_y+hleft,&amp;r);
}

coredump
07-10-2002, 04:10 AM
looks like your compiler can't find the file which contains the definition for HSPRITE.

EDIT: also, starting with the line static HSPRITE thelogo...everything after that is OUTSIDE your class function. you can't have code there! i don't know if you meant it to be in the above function or not.

b

[This message has been edited by coredump (edited 07-10-2002).]