Skirmish AI and start locations now work correctly. Enabled debug keys.

This commit is contained in:
Justin Marshall
2020-06-06 15:59:29 -07:00
parent a5d5359e16
commit 26df6c8074
9 changed files with 150 additions and 186 deletions
+61 -60
View File
@@ -332,7 +332,7 @@ void Debug_Key(unsigned input)
}
break;
case ((int)KN_F4 | (int)KN_CTRL_BIT):
case ((int)KN_F4):
Debug_Unshroud = (Debug_Unshroud == false);
Map.Flag_To_Redraw(true);
break;
@@ -363,21 +363,22 @@ void Debug_Key(unsigned input)
*=============================================================================================*/
static char const * Bench_Time(BenchType btype)
{
static char buffer[32];
int rootcount = Benches[BENCH_GAME_FRAME].Count();
if (rootcount == 0) rootcount = 1;
int roottime = Benches[BENCH_GAME_FRAME].Value();
int count = Benches[btype].Count();
int time = Benches[btype].Value();
if (count > 0 && count * time > roottime * rootcount) time = roottime / count;
int percent = 0;
if (roottime != 0 && rootcount != 0) {
percent = ((count * time) * 99) / (roottime * rootcount);
}
if (percent > 99) percent = 99;
sprintf(buffer, "%-2d%% %7d", percent, time);
return(buffer);
//static char buffer[32];
//
//int rootcount = Benches[BENCH_GAME_FRAME].Count();
//if (rootcount == 0) rootcount = 1;
//int roottime = Benches[BENCH_GAME_FRAME].Value();
//int count = Benches[btype].Count();
//int time = Benches[btype].Value();
//if (count > 0 && count * time > roottime * rootcount) time = roottime / count;
//int percent = 0;
//if (roottime != 0 && rootcount != 0) {
// percent = ((count * time) * 99) / (roottime * rootcount);
//}
//if (percent > 99) percent = 99;
//sprintf(buffer, "%-2d%% %7d", percent, time);
//return(buffer);
return "";
}
@@ -401,50 +402,50 @@ static char const * Bench_Time(BenchType btype)
*=============================================================================================*/
static void Benchmarks(MonoClass * mono)
{
static bool _first = true;
if (_first) {
_first = false;
mono->Clear();
mono->Set_Cursor(0, 0);
mono->Print(Text_String(TXT_DEBUG_PERFORMANCE));
if (Benches == NULL) {
mono->Set_Cursor(20, 15);
mono->Printf(TXT_NO_PENTIUM);
}
}
if (Benches != NULL) {
mono->Set_Cursor(1, 2);mono->Printf("%s", Bench_Time(BENCH_FINDPATH));
mono->Set_Cursor(1, 4);mono->Printf("%s", Bench_Time(BENCH_GREATEST_THREAT));
mono->Set_Cursor(1, 6);mono->Printf("%s", Bench_Time(BENCH_AI));
mono->Set_Cursor(1, 8);mono->Printf("%s", Bench_Time(BENCH_PCP));
mono->Set_Cursor(1, 10);mono->Printf("%s", Bench_Time(BENCH_EVAL_OBJECT));
mono->Set_Cursor(1, 12);mono->Printf("%s", Bench_Time(BENCH_EVAL_CELL));
mono->Set_Cursor(1, 14);mono->Printf("%s", Bench_Time(BENCH_EVAL_WALL));
mono->Set_Cursor(1, 16);mono->Printf("%s", Bench_Time(BENCH_MISSION));
mono->Set_Cursor(14, 2);mono->Printf("%s", Bench_Time(BENCH_CELL));
mono->Set_Cursor(14, 4);mono->Printf("%s", Bench_Time(BENCH_OBJECTS));
mono->Set_Cursor(14, 6);mono->Printf("%s", Bench_Time(BENCH_ANIMS));
mono->Set_Cursor(27, 2);mono->Printf("%s", Bench_Time(BENCH_PALETTE));
mono->Set_Cursor(40, 2);mono->Printf("%s", Bench_Time(BENCH_GSCREEN_RENDER));
mono->Set_Cursor(40, 4);mono->Printf("%s", Bench_Time(BENCH_SIDEBAR));
mono->Set_Cursor(40, 6);mono->Printf("%s", Bench_Time(BENCH_RADAR));
mono->Set_Cursor(40, 8);mono->Printf("%s", Bench_Time(BENCH_TACTICAL));
mono->Set_Cursor(40, 10);mono->Printf("%s", Bench_Time(BENCH_POWER));
mono->Set_Cursor(40, 12);mono->Printf("%s", Bench_Time(BENCH_SHROUD));
mono->Set_Cursor(40, 14);mono->Printf("%s", Bench_Time(BENCH_TABS));
mono->Set_Cursor(40, 16);mono->Printf("%s", Bench_Time(BENCH_BLIT_DISPLAY));
mono->Set_Cursor(66, 2);mono->Printf("%7d", Benches[BENCH_RULES].Value());
mono->Set_Cursor(66, 4);mono->Printf("%7d", Benches[BENCH_SCENARIO].Value());
for (BenchType index = BENCH_FIRST; index < BENCH_COUNT; index++) {
if (index != BENCH_RULES && index != BENCH_SCENARIO) Benches[index].Reset();
}
}
//static bool _first = true;
//if (_first) {
// _first = false;
// mono->Clear();
// mono->Set_Cursor(0, 0);
// mono->Print(Text_String(TXT_DEBUG_PERFORMANCE));
// if (Benches == NULL) {
// mono->Set_Cursor(20, 15);
// mono->Printf(TXT_NO_PENTIUM);
// }
//}
//
//if (Benches != NULL) {
// mono->Set_Cursor(1, 2);mono->Printf("%s", Bench_Time(BENCH_FINDPATH));
// mono->Set_Cursor(1, 4);mono->Printf("%s", Bench_Time(BENCH_GREATEST_THREAT));
// mono->Set_Cursor(1, 6);mono->Printf("%s", Bench_Time(BENCH_AI));
// mono->Set_Cursor(1, 8);mono->Printf("%s", Bench_Time(BENCH_PCP));
// mono->Set_Cursor(1, 10);mono->Printf("%s", Bench_Time(BENCH_EVAL_OBJECT));
// mono->Set_Cursor(1, 12);mono->Printf("%s", Bench_Time(BENCH_EVAL_CELL));
// mono->Set_Cursor(1, 14);mono->Printf("%s", Bench_Time(BENCH_EVAL_WALL));
// mono->Set_Cursor(1, 16);mono->Printf("%s", Bench_Time(BENCH_MISSION));
//
// mono->Set_Cursor(14, 2);mono->Printf("%s", Bench_Time(BENCH_CELL));
// mono->Set_Cursor(14, 4);mono->Printf("%s", Bench_Time(BENCH_OBJECTS));
// mono->Set_Cursor(14, 6);mono->Printf("%s", Bench_Time(BENCH_ANIMS));
//
// mono->Set_Cursor(27, 2);mono->Printf("%s", Bench_Time(BENCH_PALETTE));
//
// mono->Set_Cursor(40, 2);mono->Printf("%s", Bench_Time(BENCH_GSCREEN_RENDER));
// mono->Set_Cursor(40, 4);mono->Printf("%s", Bench_Time(BENCH_SIDEBAR));
// mono->Set_Cursor(40, 6);mono->Printf("%s", Bench_Time(BENCH_RADAR));
// mono->Set_Cursor(40, 8);mono->Printf("%s", Bench_Time(BENCH_TACTICAL));
// mono->Set_Cursor(40, 10);mono->Printf("%s", Bench_Time(BENCH_POWER));
// mono->Set_Cursor(40, 12);mono->Printf("%s", Bench_Time(BENCH_SHROUD));
// mono->Set_Cursor(40, 14);mono->Printf("%s", Bench_Time(BENCH_TABS));
// mono->Set_Cursor(40, 16);mono->Printf("%s", Bench_Time(BENCH_BLIT_DISPLAY));
//
// mono->Set_Cursor(66, 2);mono->Printf("%7d", Benches[BENCH_RULES].Value());
// mono->Set_Cursor(66, 4);mono->Printf("%7d", Benches[BENCH_SCENARIO].Value());
//
// for (BenchType index = BENCH_FIRST; index < BENCH_COUNT; index++) {
// if (index != BENCH_RULES && index != BENCH_SCENARIO) Benches[index].Reset();
// }
//}
}
+5 -5
View File
@@ -2812,13 +2812,13 @@ typedef enum BenchType : unsigned char {
} BenchType;
#ifdef CHEAT_KEYS
#define BStart(a) if (Benches != NULL) Benches[a].Begin()
#define BEnd(a) if (Benches != NULL) Benches[a].End()
#else
//#ifdef CHEAT_KEYS
//#define BStart(a) if (Benches != NULL) Benches[a].Begin()
//#define BEnd(a) if (Benches != NULL) Benches[a].End()
//#else
#define BStart(a)
#define BEnd(a)
#endif
//#endif
/**********************************************************************
-7
View File
@@ -868,12 +868,6 @@ void GlyphX_Assign_Houses(void)
srand(timeGetTime());
/*
** Use pre-selected start locations as long as at least one has been defined, otherwise let the original code
** in SCENARIO.CPP figure it out
*/
UseGlyphXStartLocations = false;
/*
** Assign random start positions if needed.
*/
@@ -886,7 +880,6 @@ void GlyphX_Assign_Houses(void)
for (j = 0; !preassigned && (j < Session.Players.Count()); j++) {
if (MPlayerStartLocations[j] == num_start_locations) {
preassigned = true;
UseGlyphXStartLocations = true;
}
}
if (!preassigned) {
+26 -26
View File
@@ -497,32 +497,32 @@ KeyNumType GadgetClass::Input(void)
#ifdef WIN32
#ifdef CHEAT_KEYS
if (key == KN_K && !Debug_Map && (Debug_Flag || Debug_Playtest)) {
/*
** time to create a screen shot using the PCX code (if it works)
*/
if (!Debug_MotionCapture) {
GraphicBufferClass temp_page( SeenBuff.Get_Width(),
SeenBuff.Get_Height(),
NULL,
SeenBuff.Get_Width() * SeenBuff.Get_Height());
CDFileClass file;
char filename[30];
// Hide_Mouse();
SeenBuff.Blit(temp_page);
// Show_Mouse();
for (int lp = 0; lp < 99; lp ++) {
sprintf(filename, "scrsht%02d.pcx", lp);
file.Set_Name(filename);
if (!file.Is_Available()) break;
}
file.Cache(200000);
Write_PCX_File(file, temp_page, & GamePalette);
Sound_Effect(VOC_BEEP);
}
}
//if (key == KN_K && !Debug_Map && (Debug_Flag || Debug_Playtest)) {
// /*
// ** time to create a screen shot using the PCX code (if it works)
// */
// if (!Debug_MotionCapture) {
// GraphicBufferClass temp_page( SeenBuff.Get_Width(),
// SeenBuff.Get_Height(),
// NULL,
// SeenBuff.Get_Width() * SeenBuff.Get_Height());
// CDFileClass file;
// char filename[30];
//
// // Hide_Mouse();
// SeenBuff.Blit(temp_page);
// // Show_Mouse();
// for (int lp = 0; lp < 99; lp ++) {
// sprintf(filename, "scrsht%02d.pcx", lp);
// file.Set_Name(filename);
// if (!file.Is_Available()) break;
// }
//
// file.Cache(200000);
// Write_PCX_File(file, temp_page, & GamePalette);
// Sound_Effect(VOC_BEEP);
// }
//}
#endif
#endif
+4 -2
View File
@@ -227,10 +227,12 @@ fixed HouseClass::Tiberium_Fraction(void) const
* 01/23/1995 JLB : Created. *
*=============================================================================================*/
HouseClass * HouseClass::As_Pointer(HousesType house)
{
{
if (house != HOUSE_NONE) {
for (int index = 0; index < Houses.Count(); index++) {
if (Houses.Ptr(index)->Class->House == house) {
HouseClass* houseClass = Houses.Ptr(index);
HouseTypeClass* houseTypeClass = houseClass->Class;
if (houseTypeClass->House == house) {
return(Houses.Ptr(index));
}
}
+3 -3
View File
@@ -199,9 +199,9 @@ bool Init_Game(int , char * [])
** compile flags indicate.
*/
#ifdef CHEAT_KEYS
if (Processor() >= 2) {
Benches = new Benchmark [BENCH_COUNT];
}
//if (Processor() >= 2) {
// Benches = new Benchmark [BENCH_COUNT];
//}
#endif
/*
+3 -2
View File
@@ -52,6 +52,7 @@ typedef int bool;
#endif
#endif
#pragma warning(disable : 4005)
typedef enum {
WWKEY_SHIFT_BIT = 0x100,
@@ -579,8 +580,8 @@ typedef enum KeyNumType {
KN_F11 = VK_F11,
KN_F12 = VK_F12,
KN_F2 = 59,
KN_F3 = VK_F3,
KN_F4 = VK_F4,
KN_F3 = 60,
KN_F4 = 61,
KN_F5 = VK_F5,
KN_F6 = VK_F6,
KN_F7 = VK_F7,
+2 -2
View File
@@ -95,7 +95,7 @@
<AdditionalIncludeDirectories>../external/dxsdk/Include;../external/ffmpeg-win32/include;../external/sdl2/include;./win32lib;../external/openal/include</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>false</WholeProgramOptimization>
<PreprocessorDefinitions>SCENARIO_EDITOR;WINDOWS_IGNORE_PACKING_MISMATCH;TRUE_FALSE_DEFINED;ENGLISH;WIN32;NDEBUG;_WINDOWS;_USRDLL;REDALERT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CHEAT_KEYS;SCENARIO_EDITOR;WINDOWS_IGNORE_PACKING_MISMATCH;TRUE_FALSE_DEFINED;ENGLISH;WIN32;NDEBUG;_WINDOWS;_USRDLL;REDALERT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StructMemberAlignment>1Byte</StructMemberAlignment>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -125,7 +125,7 @@
<SDLCheck>false</SDLCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<PreprocessorDefinitions>SCENARIO_EDITOR;WINDOWS_IGNORE_PACKING_MISMATCH;TRUE_FALSE_DEFINED;ENGLISH;WIN32;_DEBUG;_WINDOWS;_USRDLL;REDALERT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>CHEAT_KEYS;SCENARIO_EDITOR;WINDOWS_IGNORE_PACKING_MISMATCH;TRUE_FALSE_DEFINED;ENGLISH;WIN32;_DEBUG;_WINDOWS;_USRDLL;REDALERT_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<StructMemberAlignment>1Byte</StructMemberAlignment>
+46 -79
View File
@@ -71,7 +71,6 @@ extern int PreserveVQAScreen;
void Display_Briefing_Text_GlyphX();
extern void GlyphX_Assign_Houses(void); //ST - 8/8/2019 12:35PM
extern bool UseGlyphXStartLocations; //ST - 3/31/2020 9:54AM
//#include "WolDebug.h"
@@ -2888,7 +2887,6 @@ static void Remove_AI_Players(void)
HousesType house;
HouseClass * housep;
#if (0)
for (i = 0; i < MAX_PLAYERS; i++) {
house = (HousesType)(i + (int)HOUSE_MULTI1);
housep = HouseClass::As_Pointer (house);
@@ -2899,21 +2897,6 @@ static void Remove_AI_Players(void)
}
}
}
#else
/*
** AI players are set up like human players now. ST - 8/13/2019 1:32PM
*/
for (i = 0; i < MAX_PLAYERS; i++) {
if (i >= Session.Players.Count()) {
house = (HousesType)(i + (int)HOUSE_MULTI1);
housep = HouseClass::As_Pointer (house);
if (housep->IsHuman == false) {
housep->Clobber_All();
}
}
}
#endif
}
@@ -3092,17 +3075,11 @@ static void Create_Units(bool official)
** if there are 4 or fewer players. Unofficial maps will pick from all the
** available waypoints.
*/
#ifndef USE_GLYPHX_START_LOCATIONS
int look_for = max(4, Session.Players.Count()+Session.Options.AIPlayers);
if (!official) {
look_for = 8;
}
#else
/*
** We allow the users to choose from all available start positions, even on official maps. ST - 1/15/2020 9:19AM
*/
int look_for = Session.Players.Count();
#endif
for (int waycount = 0; waycount < 26; waycount++) {
// for (int waycount = 0; waycount < max(4, Session.Players.Count()+Session.Options.AIPlayers); waycount++) {
@@ -3156,71 +3133,61 @@ static void Create_Units(bool official)
** one of the valid locations at random. The other houses pick the furthest
** wapoint from the existing houses.
*/
if (!UseGlyphXStartLocations) {
if (numtaken == 0) {
int pick = Random_Pick(0, num_waypts-1);
centroid = waypts[pick];
taken[pick] = true;
numtaken++;
} else {
if (numtaken == 0) {
int pick = Random_Pick(0, num_waypts - 1);
centroid = waypts[pick];
taken[pick] = true;
numtaken++;
}
else {
/*
** Set all waypoints to have a score of zero in preparation for giving
** a distance score to all waypoints.
*/
int score[26];
memset(score, '\0', sizeof(score));
/*
** Scan through all waypoints and give a score as a value of the sum
** of the distances from this waypoint to all taken waypoints.
*/
for (int index = 0; index < num_waypts; index++) {
/*
** Set all waypoints to have a score of zero in preparation for giving
** a distance score to all waypoints.
** If this waypoint has not already been taken, then accumulate the
** sum of the distance between this waypoint and all other taken
** waypoints.
*/
int score[26];
memset(score, '\0', sizeof(score));
if (!taken[index]) {
for (int trypoint = 0; trypoint < num_waypts; trypoint++) {
/*
** Scan through all waypoints and give a score as a value of the sum
** of the distances from this waypoint to all taken waypoints.
*/
for (int index = 0; index < num_waypts; index++) {
/*
** If this waypoint has not already been taken, then accumulate the
** sum of the distance between this waypoint and all other taken
** waypoints.
*/
if (!taken[index]) {
for (int trypoint = 0; trypoint < num_waypts; trypoint++) {
if (taken[trypoint]) {
score[index] += Distance(Cell_Coord(waypts[index]), Cell_Coord(waypts[trypoint]));
}
if (taken[trypoint]) {
score[index] += Distance(Cell_Coord(waypts[index]), Cell_Coord(waypts[trypoint]));
}
}
}
/*
** Now find the waypoint with the largest score. This waypoint is the one
** that is furthest from all other taken waypoints.
*/
int best = 0;
int bestvalue = 0;
for (int searchindex = 0; searchindex < num_waypts; searchindex++) {
if (score[searchindex] > bestvalue || bestvalue == 0) {
bestvalue = score[searchindex];
best = searchindex;
}
}
/*
** Assign this best position to the house.
*/
centroid = waypts[best];
taken[best] = true;
numtaken++;
}
} else {
/*
** New code that respects the start locations passed in from GlyphX.
**
** ST - 1/8/2020 3:39PM
** Now find the waypoint with the largest score. This waypoint is the one
** that is furthest from all other taken waypoints.
*/
centroid = waypts[hptr->StartLocationOverride];
int best = 0;
int bestvalue = 0;
for (int searchindex = 0; searchindex < num_waypts; searchindex++) {
if (score[searchindex] > bestvalue || bestvalue == 0) {
bestvalue = score[searchindex];
best = searchindex;
}
}
/*
** Assign this best position to the house.
*/
centroid = waypts[best];
taken[best] = true;
numtaken++;
}
/*