Well, I started writing this awhile ago, before I knew what a class was (Unfortunantly) So organizing data is... Horrible and slow ;P.
My error is weird, instead of highlightin what It should be (The set my mouse is over), it highlights my last created set (Explained in a sec). My "sets" are just 2 coords. I'm not sure why, though. I've looked it over and the only reason I can see is that my data organization has screwed the possiblity of this working -,-.
Heres my problem code:
Code:
#define TeleportE '+' //Teleport Enterence
#define TeleportD '!' //Teleport Destination
#define TriggerE 't'
#define TriggerP 'p'
HANDLE hOt = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hIn = GetStdHandle(STD_INPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO inf;
CONSOLE_CURSOR_INFO Cur;
WORD Scolor;
WORD Scurso;
char CurPeice;
int Ticker, MOUSEX, MOUSEY;
COORD RSP;
char Ext[1];
//-----------------------------
BOOL Active_Trigger = 0; //|
int Active_Trigger_Id = 0; //|
//|
BOOL Active_Tele = 0; //|
int Active_Tele_Id = 0; //|
//-----------------------------
COORD TE[1000]; //Teleporter Enterence array
COORD TD[1000]; //Teleporter Destination array
int NOE = 0; //Number of Teleporters
int NOD = 0;
COORD Trigger[1000]; //Trigger Array
int NOT = 0; //Number of Triggers
COORD Effect[1000]; //Trigger Effect Array
int NOTE = 0; //Number of Trigger Effects
COORD OldCharPos[1000]; //Old char positions for effects
char OldChar[1][1000]; //Old chars for effects
//--------------------------------------------------------Problem code \/
char ReadPos(SHORT x, SHORT y) {
DWORD reader;
COORD Pos;
char EEE[1];
SHORT v;
Pos.X = x;
Pos.Y = y;
ReadConsoleOutputCharacter(hOt, &EEE[0], 1, Pos, &reader);
return EEE[0];
}
int FindTeleporter(BOOL EoE, int x, int y) { //Enterence (0) Exit (1)
int l = 0;
if(EoE == 0) { //Enterence
for(l = 0; l <= NOE; l++)
if(x == TE[l].X && y == TE[l].Y)
return l;
}
if(EoE == 1) { //Exit
for(l = 0; l <= NOD; l++)
if(x == TD[l].X && y == TD[l].Y)
return l;
}
return -1;
}
int FindTrigger(BOOL EoE, int x, int y) { //Enterence (0) Exit (1)
int l = 0;
if(EoE == 0) { //Enterence
for(l = 0; l <= NOT; l++)
if(x == Trigger[l].X && y == Trigger[l].Y)
return l;
}
if(EoE == 1) {
for(l = 0; l <= NOTE; l++)
if(x == Effect[l].X && y == Effect[l].Y)
return l;
}
return -1;
}
void ColorId(int Id, int Type) {
if(Type == 1) { //Trigger
SetConsoleCursorPosition(hOt, Trigger[Id]);
SetColor('r');
cout << TriggerE;
SetConsoleCursorPosition(hOt, Effect[Id]);
cout << TriggerP;
SetColor('o');
}
if(Type == 2) { //Teleporter
SetConsoleCursorPosition(hOt, TE[Id]);
SetColor('r');
cout << TeleportE;
SetConsoleCursorPosition(hOt, TD[Id]);
cout << TeleportD;
SetColor('o');
}
}
void ResetId(int Id, int Type) {
if(Type == 1) { //Trigger
SetConsoleCursorPosition(hOt, Trigger[Id]);
SetColor('o');
cout << TriggerE;
SetConsoleCursorPosition(hOt, Effect[Id]);
cout << TriggerP;
}
if(Type == 2) { //Teleporter
SetConsoleCursorPosition(hOt, TE[Id]);
SetColor('o');
cout << TeleportE;
SetConsoleCursorPosition(hOt, TD[Id]);
cout << TeleportD;
}
}
int ActivateNode(SHORT x, SHORT y) {
int z;
char c;
if(Active_Tele_Id > 0)
ResetId(Active_Tele_Id, 2);
Active_Tele = 0;
Active_Tele_Id = 0;
if(Active_Trigger_Id > 0)
ResetId(Active_Trigger_Id, 1);
Active_Trigger = 0;
Active_Trigger_Id = 0;
c = ReadPos(x, y);
if(c == Blank)
return 0;
if(c == TriggerE) {
Active_Trigger = 1;
Active_Trigger_Id = FindTrigger(0, x, y);
if(Active_Trigger_Id == -1)
return 0;
ColorId(Active_Trigger_Id, 1);
return 1;
}
if(c == TriggerP) {
Active_Trigger = 1;
Active_Trigger_Id = FindTrigger(1, x, y);
if(Active_Trigger_Id == -1)
return 0;
ColorId(Active_Trigger_Id, 1);
return 1;
}
if(c == TeleportE) {
Active_Tele = 1;
Active_Tele_Id = FindTeleporter(0, x, y);
if(Active_Tele_Id == -1)
return 0;
ColorId(Active_Tele_Id, 2);
return 1;
}
if(c == TeleportD) {
Active_Tele = 1;
Active_Tele_Id = FindTeleporter(1, x, y);
if(Active_Tele_Id == -1)
return 0;
ColorId(Active_Tele_Id, 2);
return 1;
}
}
As you can see, this is very bad data organization, but it would take to long to convert this, c-type no class style is pritty inset in this particular program. I dont see any reason that this would select only my last set. Not only that, once it does it wont deselect or reselect until I make a new set, and if I hit select pair after I make a new set, it selects the newest set. I dont see why... Does anyone?