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; break;
case ((int)KN_F4 | (int)KN_CTRL_BIT): case ((int)KN_F4):
Debug_Unshroud = (Debug_Unshroud == false); Debug_Unshroud = (Debug_Unshroud == false);
Map.Flag_To_Redraw(true); Map.Flag_To_Redraw(true);
break; break;
@@ -363,21 +363,22 @@ void Debug_Key(unsigned input)
*=============================================================================================*/ *=============================================================================================*/
static char const * Bench_Time(BenchType btype) static char const * Bench_Time(BenchType btype)
{ {
static char buffer[32]; //static char buffer[32];
//
int rootcount = Benches[BENCH_GAME_FRAME].Count(); //int rootcount = Benches[BENCH_GAME_FRAME].Count();
if (rootcount == 0) rootcount = 1; //if (rootcount == 0) rootcount = 1;
int roottime = Benches[BENCH_GAME_FRAME].Value(); //int roottime = Benches[BENCH_GAME_FRAME].Value();
int count = Benches[btype].Count(); //int count = Benches[btype].Count();
int time = Benches[btype].Value(); //int time = Benches[btype].Value();
if (count > 0 && count * time > roottime * rootcount) time = roottime / count; //if (count > 0 && count * time > roottime * rootcount) time = roottime / count;
int percent = 0; //int percent = 0;
if (roottime != 0 && rootcount != 0) { //if (roottime != 0 && rootcount != 0) {
percent = ((count * time) * 99) / (roottime * rootcount); // percent = ((count * time) * 99) / (roottime * rootcount);
} //}
if (percent > 99) percent = 99; //if (percent > 99) percent = 99;
sprintf(buffer, "%-2d%% %7d", percent, time); //sprintf(buffer, "%-2d%% %7d", percent, time);
return(buffer); //return(buffer);
return "";
} }
@@ -401,50 +402,50 @@ static char const * Bench_Time(BenchType btype)
*=============================================================================================*/ *=============================================================================================*/
static void Benchmarks(MonoClass * mono) static void Benchmarks(MonoClass * mono)
{ {
static bool _first = true; //static bool _first = true;
if (_first) { //if (_first) {
_first = false; // _first = false;
mono->Clear(); // mono->Clear();
mono->Set_Cursor(0, 0); // mono->Set_Cursor(0, 0);
mono->Print(Text_String(TXT_DEBUG_PERFORMANCE)); // mono->Print(Text_String(TXT_DEBUG_PERFORMANCE));
if (Benches == NULL) { // if (Benches == NULL) {
mono->Set_Cursor(20, 15); // mono->Set_Cursor(20, 15);
mono->Printf(TXT_NO_PENTIUM); // mono->Printf(TXT_NO_PENTIUM);
} // }
} //}
//
if (Benches != NULL) { //if (Benches != NULL) {
mono->Set_Cursor(1, 2);mono->Printf("%s", Bench_Time(BENCH_FINDPATH)); // 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, 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, 6);mono->Printf("%s", Bench_Time(BENCH_AI));
mono->Set_Cursor(1, 8);mono->Printf("%s", Bench_Time(BENCH_PCP)); // 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, 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, 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, 14);mono->Printf("%s", Bench_Time(BENCH_EVAL_WALL));
mono->Set_Cursor(1, 16);mono->Printf("%s", Bench_Time(BENCH_MISSION)); // 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, 2);mono->Printf("%s", Bench_Time(BENCH_CELL));
mono->Set_Cursor(14, 4);mono->Printf("%s", Bench_Time(BENCH_OBJECTS)); // 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(14, 6);mono->Printf("%s", Bench_Time(BENCH_ANIMS));
//
mono->Set_Cursor(27, 2);mono->Printf("%s", Bench_Time(BENCH_PALETTE)); // 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, 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, 4);mono->Printf("%s", Bench_Time(BENCH_SIDEBAR));
mono->Set_Cursor(40, 6);mono->Printf("%s", Bench_Time(BENCH_RADAR)); // 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, 8);mono->Printf("%s", Bench_Time(BENCH_TACTICAL));
mono->Set_Cursor(40, 10);mono->Printf("%s", Bench_Time(BENCH_POWER)); // 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, 12);mono->Printf("%s", Bench_Time(BENCH_SHROUD));
mono->Set_Cursor(40, 14);mono->Printf("%s", Bench_Time(BENCH_TABS)); // 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(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, 2);mono->Printf("%7d", Benches[BENCH_RULES].Value());
mono->Set_Cursor(66, 4);mono->Printf("%7d", Benches[BENCH_SCENARIO].Value()); // mono->Set_Cursor(66, 4);mono->Printf("%7d", Benches[BENCH_SCENARIO].Value());
//
for (BenchType index = BENCH_FIRST; index < BENCH_COUNT; index++) { // for (BenchType index = BENCH_FIRST; index < BENCH_COUNT; index++) {
if (index != BENCH_RULES && index != BENCH_SCENARIO) Benches[index].Reset(); // if (index != BENCH_RULES && index != BENCH_SCENARIO) Benches[index].Reset();
} // }
} //}
} }
+5 -5
View File
@@ -2812,13 +2812,13 @@ typedef enum BenchType : unsigned char {
} BenchType; } BenchType;
#ifdef CHEAT_KEYS //#ifdef CHEAT_KEYS
#define BStart(a) if (Benches != NULL) Benches[a].Begin() //#define BStart(a) if (Benches != NULL) Benches[a].Begin()
#define BEnd(a) if (Benches != NULL) Benches[a].End() //#define BEnd(a) if (Benches != NULL) Benches[a].End()
#else //#else
#define BStart(a) #define BStart(a)
#define BEnd(a) #define BEnd(a)
#endif //#endif
/********************************************************************** /**********************************************************************
-7
View File
@@ -868,12 +868,6 @@ void GlyphX_Assign_Houses(void)
srand(timeGetTime()); 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. ** Assign random start positions if needed.
*/ */
@@ -886,7 +880,6 @@ void GlyphX_Assign_Houses(void)
for (j = 0; !preassigned && (j < Session.Players.Count()); j++) { for (j = 0; !preassigned && (j < Session.Players.Count()); j++) {
if (MPlayerStartLocations[j] == num_start_locations) { if (MPlayerStartLocations[j] == num_start_locations) {
preassigned = true; preassigned = true;
UseGlyphXStartLocations = true;
} }
} }
if (!preassigned) { if (!preassigned) {
+26 -26
View File
@@ -497,32 +497,32 @@ KeyNumType GadgetClass::Input(void)
#ifdef WIN32 #ifdef WIN32
#ifdef CHEAT_KEYS #ifdef CHEAT_KEYS
if (key == KN_K && !Debug_Map && (Debug_Flag || Debug_Playtest)) { //if (key == KN_K && !Debug_Map && (Debug_Flag || Debug_Playtest)) {
/* // /*
** time to create a screen shot using the PCX code (if it works) // ** time to create a screen shot using the PCX code (if it works)
*/ // */
if (!Debug_MotionCapture) { // if (!Debug_MotionCapture) {
GraphicBufferClass temp_page( SeenBuff.Get_Width(), // GraphicBufferClass temp_page( SeenBuff.Get_Width(),
SeenBuff.Get_Height(), // SeenBuff.Get_Height(),
NULL, // NULL,
SeenBuff.Get_Width() * SeenBuff.Get_Height()); // SeenBuff.Get_Width() * SeenBuff.Get_Height());
CDFileClass file; // CDFileClass file;
char filename[30]; // char filename[30];
//
// Hide_Mouse(); // // Hide_Mouse();
SeenBuff.Blit(temp_page); // SeenBuff.Blit(temp_page);
// Show_Mouse(); // // Show_Mouse();
for (int lp = 0; lp < 99; lp ++) { // for (int lp = 0; lp < 99; lp ++) {
sprintf(filename, "scrsht%02d.pcx", lp); // sprintf(filename, "scrsht%02d.pcx", lp);
file.Set_Name(filename); // file.Set_Name(filename);
if (!file.Is_Available()) break; // if (!file.Is_Available()) break;
} // }
//
file.Cache(200000); // file.Cache(200000);
Write_PCX_File(file, temp_page, & GamePalette); // Write_PCX_File(file, temp_page, & GamePalette);
Sound_Effect(VOC_BEEP); // Sound_Effect(VOC_BEEP);
} // }
} //}
#endif #endif
#endif #endif
+3 -1
View File
@@ -230,7 +230,9 @@ HouseClass * HouseClass::As_Pointer(HousesType house)
{ {
if (house != HOUSE_NONE) { if (house != HOUSE_NONE) {
for (int index = 0; index < Houses.Count(); index++) { 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)); return(Houses.Ptr(index));
} }
} }
+3 -3
View File
@@ -199,9 +199,9 @@ bool Init_Game(int , char * [])
** compile flags indicate. ** compile flags indicate.
*/ */
#ifdef CHEAT_KEYS #ifdef CHEAT_KEYS
if (Processor() >= 2) { //if (Processor() >= 2) {
Benches = new Benchmark [BENCH_COUNT]; // Benches = new Benchmark [BENCH_COUNT];
} //}
#endif #endif
/* /*
+3 -2
View File
@@ -52,6 +52,7 @@ typedef int bool;
#endif #endif
#endif #endif
#pragma warning(disable : 4005)
typedef enum { typedef enum {
WWKEY_SHIFT_BIT = 0x100, WWKEY_SHIFT_BIT = 0x100,
@@ -579,8 +580,8 @@ typedef enum KeyNumType {
KN_F11 = VK_F11, KN_F11 = VK_F11,
KN_F12 = VK_F12, KN_F12 = VK_F12,
KN_F2 = 59, KN_F2 = 59,
KN_F3 = VK_F3, KN_F3 = 60,
KN_F4 = VK_F4, KN_F4 = 61,
KN_F5 = VK_F5, KN_F5 = VK_F5,
KN_F6 = VK_F6, KN_F6 = VK_F6,
KN_F7 = VK_F7, 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> <AdditionalIncludeDirectories>../external/dxsdk/Include;../external/ffmpeg-win32/include;../external/sdl2/include;./win32lib;../external/openal/include</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<WholeProgramOptimization>false</WholeProgramOptimization> <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> <StructMemberAlignment>1Byte</StructMemberAlignment>
<ExceptionHandling>false</ExceptionHandling> <ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -125,7 +125,7 @@
<SDLCheck>false</SDLCheck> <SDLCheck>false</SDLCheck>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <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> <ExceptionHandling>false</ExceptionHandling>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<StructMemberAlignment>1Byte</StructMemberAlignment> <StructMemberAlignment>1Byte</StructMemberAlignment>
+3 -36
View File
@@ -71,7 +71,6 @@ extern int PreserveVQAScreen;
void Display_Briefing_Text_GlyphX(); void Display_Briefing_Text_GlyphX();
extern void GlyphX_Assign_Houses(void); //ST - 8/8/2019 12:35PM extern void GlyphX_Assign_Houses(void); //ST - 8/8/2019 12:35PM
extern bool UseGlyphXStartLocations; //ST - 3/31/2020 9:54AM
//#include "WolDebug.h" //#include "WolDebug.h"
@@ -2888,7 +2887,6 @@ static void Remove_AI_Players(void)
HousesType house; HousesType house;
HouseClass * housep; HouseClass * housep;
#if (0)
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
house = (HousesType)(i + (int)HOUSE_MULTI1); house = (HousesType)(i + (int)HOUSE_MULTI1);
housep = HouseClass::As_Pointer (house); 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 ** if there are 4 or fewer players. Unofficial maps will pick from all the
** available waypoints. ** available waypoints.
*/ */
#ifndef USE_GLYPHX_START_LOCATIONS
int look_for = max(4, Session.Players.Count()+Session.Options.AIPlayers); int look_for = max(4, Session.Players.Count()+Session.Options.AIPlayers);
if (!official) { if (!official) {
look_for = 8; 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 < 26; waycount++) {
// for (int waycount = 0; waycount < max(4, Session.Players.Count()+Session.Options.AIPlayers); waycount++) { // for (int waycount = 0; waycount < max(4, Session.Players.Count()+Session.Options.AIPlayers); waycount++) {
@@ -3156,14 +3133,13 @@ static void Create_Units(bool official)
** one of the valid locations at random. The other houses pick the furthest ** one of the valid locations at random. The other houses pick the furthest
** wapoint from the existing houses. ** wapoint from the existing houses.
*/ */
if (!UseGlyphXStartLocations) {
if (numtaken == 0) { if (numtaken == 0) {
int pick = Random_Pick(0, num_waypts - 1); int pick = Random_Pick(0, num_waypts - 1);
centroid = waypts[pick]; centroid = waypts[pick];
taken[pick] = true; taken[pick] = true;
numtaken++; numtaken++;
} else { }
else {
/* /*
** Set all waypoints to have a score of zero in preparation for giving ** Set all waypoints to have a score of zero in preparation for giving
@@ -3213,15 +3189,6 @@ static void Create_Units(bool official)
taken[best] = true; taken[best] = true;
numtaken++; numtaken++;
} }
} else {
/*
** New code that respects the start locations passed in from GlyphX.
**
** ST - 1/8/2020 3:39PM
*/
centroid = waypts[hptr->StartLocationOverride];
}
/* /*
** Assign the center of this house to the waypoint location. ** Assign the center of this house to the waypoint location.