Seven agents took over tear and contact collision, NPC death with blood and gibs, champions, PathFinder, the Gaper's kin, the player's death with the game over screen, item pedestals with collectible pickup, AddCollectible and EvaluateItems, room state save and restore, GameState::read, pressure plates, fireplaces, entity lights, ambient sounds, and one Lua callback enum with gated runners. Integration reconstructed Room::Update's loot preview and Entity_NPC::UpdatePickupGhosts and replaced a leftover Sacred Orb stub that stopped every pedestal roll. Under gdb: Gapers die with blood and gibs, a cleared room opens its doors, the treasure room's item is taken (banner, costume, stats: a Magic Mushroom gives damage 3.5 -> 6.12 and a heart), death leads to the game over diary, and a saved run is read back on the next boot with Continue offered. 3028 functions taken over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
91 lines
3.4 KiB
C++
91 lines
3.4 KiB
C++
#include "classes.h"
|
|
#include "data.h"
|
|
#include "gl.h"
|
|
#include "kage_sound.h"
|
|
#include "lua_engine.h"
|
|
#include "manager.h"
|
|
#include "platform.h"
|
|
#include <SDL3/SDL_video.h>
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <ctime>
|
|
#include <string>
|
|
|
|
constexpr const char* GAME_VERSION = "J460";
|
|
constexpr const char* LOCALHOST_FLAG = "--localhost_match";
|
|
constexpr const char* RESOURCES_FLAG = "--resources";
|
|
constexpr const char* MUTE_FLAG = "--mute";
|
|
constexpr const char* LOG_FILE = "log.txt";
|
|
constexpr const char* LOCALHOST_LOG = "localhost/log_";
|
|
constexpr const char* CLAMP_COLOR_EXTENSION = "GL_ARB_color_buffer_float";
|
|
// GL 3.0, as major * 10 + minor.
|
|
constexpr int CLAMP_COLOR_VERSION = 30;
|
|
constexpr int VERSION_MINOR_DIGITS = 10;
|
|
|
|
// The context's GL version as major * 10 + minor, 0 without one.
|
|
static int gl_version_get()
|
|
{
|
|
const char* version = gl.GetString ? (const char*)gl.GetString(GL_VERSION) : nullptr;
|
|
int major = 0;
|
|
int minor = 0;
|
|
|
|
if (version) std::sscanf(version, "%d.%d", &major, &minor);
|
|
return major * VERSION_MINOR_DIGITS + minor;
|
|
}
|
|
|
|
// 00931050 Starts the engine and the game, logging the command line, then runs one frame at a time at 60 Hz until
|
|
// the window closes. "--localhost_match" logs to a timestamped file under localhost/ instead of log.txt.
|
|
// The theora log hook, COM, the Win32 window-move listener, Steam and the Windows power and timer settings are left
|
|
// out. A debug flag nothing sets (DAT_00c35e68) would skip the update and render.
|
|
int IsaacMain(int argc, uint8_t** argv)
|
|
{
|
|
platform.directories_load();
|
|
|
|
std::string logPath = platform.userDataDirectory + LOG_FILE;
|
|
for (int i = 0; i < argc; i++)
|
|
{
|
|
if (std::strcmp((const char*)argv[i], LOCALHOST_FLAG) != 0) continue;
|
|
logPath = platform.userDataDirectory + LOCALHOST_LOG + std::to_string(std::time(nullptr)) + ".txt";
|
|
break;
|
|
}
|
|
log_open(logPath);
|
|
platform.bindings_load();
|
|
platform.engine_init();
|
|
|
|
log_printf(LOG_INFO, "Command Line: \n");
|
|
for (int i = 0; i < argc; i++) log_printf(LOG_INFO, "\t%s\n", (const char*)argv[i]);
|
|
log_printf(LOG_INFO, "Game Version: %s \n", GAME_VERSION);
|
|
if (gl.ClampColor && (SDL_GL_ExtensionSupported(CLAMP_COLOR_EXTENSION) || gl_version_get() >= CLAMP_COLOR_VERSION))
|
|
gl.ClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE);
|
|
|
|
IsaacStartup(argc, argv);
|
|
while (true)
|
|
{
|
|
g_manager->framesPerSecond = platform.frame_begin();
|
|
// 00a714e0 KAGE::System::update ran here without polling input: its video clips, lobby commands, deferred heap
|
|
// frees and EOS tick have nothing to run, and the log is flushed with every message.
|
|
Manager::Update();
|
|
g_manager->Render();
|
|
if (g_game) lua_engine_get().gc_update();
|
|
if (platform.isQuitRequested) break;
|
|
platform.frame_wait();
|
|
}
|
|
|
|
Isaac::Shutdown();
|
|
platform.engine_shutdown();
|
|
return 0;
|
|
}
|
|
|
|
// The Linux entry point: "--resources <dir>" says where the imported game files are, "--mute" plays nothing, then the
|
|
// game's own main runs.
|
|
int main(int argc, char** argv)
|
|
{
|
|
for (int i = 1; i < argc; i++)
|
|
{
|
|
if (std::strcmp(argv[i], MUTE_FLAG) == 0) KAGE::Sound::manager.isMuted = true;
|
|
else if (std::strcmp(argv[i], RESOURCES_FLAG) == 0 && i + 1 < argc)
|
|
dataDirectory = std::string(argv[i + 1]) + "/";
|
|
}
|
|
return IsaacMain(argc, (uint8_t**)argv);
|
|
}
|