### Get libcurl installation prefix Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command shows the installation prefix used when libcurl was installed. Libcurl's library and header files are typically located relative to this prefix (e.g., $prefix/lib, $prefix/include). ```shell curl-config --prefix ``` -------------------------------- ### Get libcurl build features Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command lists the main features with which the installed libcurl was built, such as SSL, KRB4, or IPv6. The output may contain none, one, or several keywords separated by newlines. ```shell curl-config --feature ``` -------------------------------- ### Build a single file with libcurl Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This example demonstrates a one-line command to compile a single C file (example.c) using libcurl. It dynamically fetches the compiler and linker options using curl-config. ```shell `curl-config --cc --cflags --libs` -o example example.c ``` -------------------------------- ### C Example: Setting a Custom Write Callback Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_setopt.html This example demonstrates how to set a custom function to handle incoming data using CURLOPT_WRITEFUNCTION. The provided callback function will be executed by libcurl for data reception. The associated data pointer for the callback is set using CURLOPT_WRITEDATA. ```c CURLcode res; // Assume 'my_write_function' is defined elsewhere with the correct signature res = curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, my_write_function); // Optionally set user data for the callback void *user_data = /* ... */; res = curl_easy_setopt(handle, CURLOPT_WRITEDATA, user_data); ``` -------------------------------- ### Check libcurl SSL support Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command checks if the installed libcurl was built with SSL support by filtering the output of the --feature option. It helps in understanding the capabilities of the libcurl installation. ```shell curl-config --feature | grep SSL ``` -------------------------------- ### Get installed libcurl version Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command retrieves the version information of the installed libcurl. It's a straightforward way to identify the specific version being used. ```shell curl-config --version ``` -------------------------------- ### Get libcurl compiler options Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command outputs the necessary compiler options (CFLAGS), including include paths, for compiling files that use libcurl. This is crucial for setting up the build environment correctly. ```shell curl-config --cflags ``` -------------------------------- ### Get libcurl linker options Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command displays the complete set of libraries and linker options required to link an application with libcurl. It is essential for compiling applications that utilize libcurl functionalities. ```shell curl-config --libs ``` -------------------------------- ### SCons Build System Utilities (Python) Source: https://context7.com/id-software/doom-3/llms.txt This section details the use of SCons, a Python-based build system, for managing the compilation process. It includes setup for buffered output to handle parallel builds effectively and custom builders for creating game PAK files and safely compiling shared libraries with undefined symbol checking. ```python # neo/sys/scons/scons_utils.py from scons_utils import * import SCons.Environment # Create SCons environment with buffered output for parallel builds env = SCons.Environment.Environment() # Enable buffered output (essential for -j parallel builds) SetupBufferedOutput(env, silent=False) # silent=True hides successful output # Add utility functions to environment SetupUtils(env) # Build a game PAK file (strips and zips the game library) env.Command( target='base/pak001.pk4', source='gamex86.so', action=env.BuildGamePak ) # Use safe shared library builder with undefined symbol checking game_lib = env.SharedLibrarySafe( target='gamex86.so', source=['Game.cpp', 'Player.cpp', 'AI.cpp'] ) # Set allowed undefined symbols (for engine-provided symbols) env['ALLOWED_SYMBOLS'] = [ '_Z7idAllocjS_', # Memory allocator from engine '_Z6idFreePv', # Memory free from engine ] ``` ```python # Example SConstruct usage: # import sys # sys.path.append('sys/scons') # from scons_utils import * # # env = Environment() # SetupBufferedOutput(env, silent=False) # SetupUtils(env) # # # Extract version information # setup = idSetupBase() # protocol = setup.ExtractProtocolVersion() # engine_ver = setup.ExtractEngineVersion() # build_ver = setup.ExtractBuildVersion() # # print(f"Building Doom 3 {engine_ver} (Protocol {protocol}, Build {build_ver})") # # # Build targets # game = env.SharedLibrarySafe('gamex86.so', Glob('game/*.cpp')) # pak = env.Command('base/game01.pk4', game, env.BuildGamePak) # # # M4 template processing # setup.M4Processing('config.txt.m4', { # 'VERSION': engine_ver, # 'PROTOCOL': protocol, # 'BUILD': build_ver # }) ``` -------------------------------- ### Set HTTP POST data using curl_easy_setopt Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_formadd.html This example shows how to set the constructed multipart POST data for a libcurl easy handle using `curl_easy_setopt` with the `CURLOPT_HTTPPOST` option. The `post` pointer, created by `curl_formadd`, is passed here. ```c CURL *curl = curl_easy_init(); struct HttpPost* post = NULL; struct HttpPost* last = NULL; /* ... (code to populate 'post' using curl_formadd) ... */ curl_easy_setopt(curl, CURLOPT_HTTPPOST, post); /* ... (execute the request) ... */ curl_easy_cleanup(curl); /* It's important NOT to free 'post' before curl_easy_cleanup */ ``` -------------------------------- ### C Example: Enabling Verbose Output with CURLOPT_VERBOSE Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_setopt.html Setting CURLOPT_VERBOSE to a non-zero value enables verbose output from libcurl, which is sent to stderr or a custom stream. This is invaluable for debugging protocol interactions and understanding transfer operations. It is generally not recommended for production environments. ```c CURLcode res; long verbose_level = 1; // Enable verbose output res = curl_easy_setopt(handle, CURLOPT_VERBOSE, verbose_level); ``` -------------------------------- ### C Example: Including Headers in Output with CURLOPT_HEADER Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_setopt.html The CURLOPT_HEADER option, when set to a non-zero value, instructs libcurl to include protocol-specific headers within the body output. This is particularly relevant for protocols like HTTP where headers precede the actual data. ```c CURLcode res; long include_header = 1; // Include headers res = curl_easy_setopt(handle, CURLOPT_HEADER, include_header); ``` -------------------------------- ### Initialize and Use Doom 3 3D Positional Audio System Source: https://context7.com/id-software/doom-3/llms.txt Demonstrates initializing the sound system, creating and positioning sound emitters, loading and playing sound shaders, modifying sound parameters, and placing the listener. It also shows playing UI sounds and checking sound playback status. Dependencies include `idSoundSystem`, `idRenderWorld`, `idSoundWorld`, `idSoundEmitter`, `idSoundShader`, and `declManager`. ```cpp // neo/sound/sound.h extern idSoundSystem *soundSystem; void SetupAudioExample(idRenderWorld *renderWorld) { // Initialize sound system soundSystem->InitHW(); // Allocate sound world (linked to render world for occlusion) idSoundWorld *soundWorld = soundSystem->AllocSoundWorld(renderWorld); soundSystem->SetPlayingSoundWorld(soundWorld); // Create a sound emitter for 3D positioned audio idSoundEmitter *emitter = soundWorld->AllocSoundEmitter(); // Position the sound emitter in 3D space idVec3 soundPos(100.0f, 50.0f, 0.0f); emitter->UpdateEmitter(soundPos, 0, NULL); // Load and play a sound shader const idSoundShader *gunfireSound = declManager->FindSound("weapons/machinegun/fire"); int channelID = emitter->StartSound(gunfireSound, SCHANNEL_ANY, 0.0f, 0); // Modify sound parameters soundShaderParms_t parms; parms.volume = 0.8f; parms.minDistance = 10.0f; parms.maxDistance = 500.0f; emitter->ModifySound(SCHANNEL_ANY, &parms); // Fade out a sound over 2 seconds emitter->FadeSound(SCHANNEL_ANY, 0.0f, 2.0f); // Position listener (camera/player) idVec3 listenerPos(0.0f, 0.0f, 64.0f); idMat3 listenerAxis = idAngles(0, 0, 0).ToMat3(); soundWorld->PlaceListener(listenerPos, listenerAxis, 0, gameLocal.time, "area1"); // Play a UI sound (no 3D positioning) soundWorld->PlayShaderDirectly("sounds/ui/button_click", -1); // Check if sound is playing if (emitter->CurrentlyPlaying()) { float amplitude = emitter->CurrentAmplitude(); common->Printf("Sound amplitude: %f\n", amplitude); } // Cleanup soundWorld->StopAllSounds(); soundWorld->ClearAllSoundEmitters(); } ``` -------------------------------- ### Render Entities and Lights in a 3D World (C++) Source: https://context7.com/id-software/doom-3/llms.txt Illustrates the process of setting up a 3D rendering scene, including allocating a render world, defining and updating entities with models and shaders, adding dynamic lights, and configuring camera views for rendering. ```cpp // neo/renderer/RenderSystem.h and RenderWorld.h extern idRenderSystem *renderSystem; void SetupRenderingExample() { // Allocate a render world idRenderWorld *renderWorld = renderSystem->AllocRenderWorld(); // Load a 3D model renderEntity_t entity; memset(&entity, 0, sizeof(entity)); entity.hModel = renderModelManager->FindModel("models/weapons/machinegun.lwo"); entity.origin = idVec3(100.0f, 50.0f, 0.0f); entity.axis = mat3_identity; entity.shaderParms[SHADERPARM_RED] = 1.0f; entity.shaderParms[SHADERPARM_GREEN] = 1.0f; entity.shaderParms[SHADERPARM_BLUE] = 1.0f; entity.shaderParms[SHADERPARM_ALPHA] = 1.0f; // Add entity to world, returns handle for updates qhandle_t entityHandle = renderWorld->AddEntityDef(&entity); // Update entity position and orientation entity.origin = idVec3(150.0f, 75.0f, 10.0f); entity.axis = idAngles(0, 45, 0).ToMat3(); // Rotate 45 degrees renderWorld->UpdateEntityDef(entityHandle, &entity); // Add a dynamic light renderLight_t light; memset(&light, 0, sizeof(light)); light.origin = idVec3(100.0f, 100.0f, 200.0f); light.lightRadius = idVec3(512.0f, 512.0f, 512.0f); // Omni light light.shaderParms[SHADERPARM_RED] = 1.0f; light.shaderParms[SHADERPARM_GREEN] = 0.8f; light.shaderParms[SHADERPARM_BLUE] = 0.6f; light.pointLight = true; light.shader = declManager->FindMaterial("lights/ambientLight"); qhandle_t lightHandle = renderWorld->AddLightDef(&light); // Setup camera view renderView_t view; memset(&view, 0, sizeof(view)); view.vieworg = idVec3(0.0f, -200.0f, 100.0f); view.viewaxis = idAngles(15, 0, 0).ToMat3(); view.fov_x = 90.0f; view.fov_y = 73.74f; // 4:3 aspect ratio view.width = 1024; view.height = 768; view.time = gameLocal.time; // Render the scene renderWorld->RenderScene(&view); // Cleanup when done renderWorld->FreeLightDef(lightHandle); renderWorld->FreeEntityDef(entityHandle); renderSystem->FreeRenderWorld(renderWorld); } ``` -------------------------------- ### Get libcurl version in numerical mode Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command outputs the libcurl version number in a hexadecimal format, where each part (major, minor, patch) is represented by 8 bits. For example, libcurl 7.7.4 would appear as 070704. ```shell curl-config --vernum ``` -------------------------------- ### Display Usage Help Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl.html Prints a help message detailing the available command-line options and their usage. This is a fundamental option for users to understand how to operate curl. ```bash curl -h curl --help ``` -------------------------------- ### C Example: Preventing Signal Handling with CURLOPT_NOSIGNAL Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_setopt.html The CURLOPT_NOSIGNAL option, when set to a non-zero value, prevents libcurl from installing signal handlers or sending signals. This is primarily useful for multi-threaded applications on Unix-like systems to avoid signal-related issues while using timeout options. (Added in 7.10) ```c CURLcode res; long no_signals = 1; // Prevent signal usage res = curl_easy_setopt(handle, CURLOPT_NOSIGNAL, no_signals); ``` -------------------------------- ### C++ UI System: Manage Menus, HUD, and Interface Elements Source: https://context7.com/id-software/doom-3/llms.txt Demonstrates loading UI definitions from files, setting and retrieving state variables (string, int, float, bool), handling input events, activating, rendering, and cleaning up UI elements using the `idUserInterfaceManager` and `idUserInterface` classes. ```cpp // neo/ui/UserInterface.h extern idUserInterfaceManager *uiManager; void UserInterfaceExample() { // Load UI definition idUserInterface *mainMenu = uiManager->Alloc(); mainMenu->InitFromFile("guis/mainmenu.gui"); // Set UI state variables mainMenu->SetStateString("player_name", "Player1"); mainMenu->SetStateInt("player_health", 100); mainMenu->SetStateFloat("player_armor", 75.5f); mainMenu->SetStateBool("has_key", true); // Read UI state const char *name = mainMenu->GetStateString("player_name"); int health = mainMenu->GetStateInt("player_health"); bool hasKey = mainMenu->GetStateBool("has_key"); common->Printf("Player: %s, Health: %d, Has key: %d\n", name, health, hasKey); // Handle input events sysEvent_t ev; ev.evType = SE_KEY; ev.evValue = K_MOUSE1; ev.evValue2 = 1; // Key down const char *result = mainMenu->HandleEvent(&ev, gameLocal.time); if (result && result[0]) { common->Printf("UI event result: %s\n", result); // Handle button actions if (idStr::Icmp(result, "start_game") == 0) { // Start new game } else if (idStr::Icmp(result, "quit") == 0) { // Quit game } } // Activate/deactivate UI mainMenu->Activate(true, gameLocal.time); // Render UI mainMenu->Redraw(gameLocal.time); // Trigger UI events mainMenu->Trigger(gameLocal.time); // Cleanup uiManager->DeAlloc(mainMenu); } ``` -------------------------------- ### Display curl-config help Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command displays a list of all available options for the curl-config utility, providing a quick reference for its usage. ```shell curl-config --help ``` -------------------------------- ### HTTP GET with Data Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl.html Forces data specified with -d or --data-binary to be sent using an HTTP GET request instead of POST. The data is appended to the URL as a query string. If used with -I, data is appended to a HEAD request. ```bash curl -G -d "param=value" [URL] ``` -------------------------------- ### Doom 3 Game Logic: Entity Spawning and Management Source: https://context7.com/id-software/doom-3/llms.txt Illustrates core game logic operations including map initialization, player spawning, entity definition-based spawning, and running game frames with user commands. It also covers basic multiplayer connection management and cleanup. Requires access to the global 'game' pointer and gameLocal context. ```cpp // neo/game/Game.h extern idGame *game; void GameLogicExample() { // Initialize game for a map game->InitFromNewMap("testmaps/test_box.map", renderWorld, soundWorld, true, // Is server false, // Is client 12345); // Random seed // Spawn player entity game->SpawnPlayer(0); // Client number 0 // Get player entity idPlayer *player = gameLocal.GetLocalPlayer(); if (player) { // Set player position player->SetOrigin(idVec3(0, 0, 64)); player->SetViewAngles(idAngles(0, 90, 0)); // Give player items player->GiveInventoryItem(declManager->FindType(DECL_ENTITYDEF, "weapon_machinegun")); player->GiveHealthPool(25.0f); // Player health and armor player->health = 100; player->inventory.armor = 50; } // Spawn an entity from entity definition idDict spawnArgs; spawnArgs.Set("classname", "monster_demon_imp"); spawnArgs.SetVector("origin", "100 200 0"); spawnArgs.SetAngles("angles", "0 180 0"); idEntity *monster = gameLocal.SpawnEntityType( idAI::Type, &spawnArgs); if (monster) { monster->PostEventMS(&EV_Activate, 0, player); } // Run game frame with player input usercmd_t cmd; memset(&cmd, 0, sizeof(cmd)); cmd.forwardmove = 127; // Move forward cmd.rightmove = 0; cmd.upmove = 0; cmd.angles[YAW] = ANGLE2SHORT(90); gameReturn_t ret = game->RunFrame(&cmd); // Handle multiplayer game->ServerClientConnect(0, "player_guid_12345"); game->ServerClientDisconnect(0); // Cleanup game->MapShutdown(); game->Shutdown(); } ``` -------------------------------- ### curl_share_setopt Function Signature and Example Usage Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_share_setopt.html This snippet shows the C function signature for curl_share_setopt and provides an example of how it might be used to set a lock function for shared data. It highlights the need for including the curl/curl.h header. ```c #include CURLSHcode curl_share_setopt(CURLSH *share, CURLSHoption option, parameter); // Example usage: void my_lock_function(CURL *handle, curl_lock_data data, curl_lock_access access, void *userptr) { // Implementation to lock data } CURLSH *share_handle = curl_share_init(); if (share_handle) { curl_share_setopt(share_handle, CURLSHOPT_LOCKFUNC, my_lock_function); // ... other options ... } ``` -------------------------------- ### Framework Core System Headers (C++) Source: https://github.com/id-software/doom-3/blob/master/neo/sys/linux/SDK-1.3.list.txt This snippet includes C++ header files for core framework systems in Doom 3. It covers essential components like asynchronous network systems, build-time defines and versioning, command system, and console variable system. These headers define the interfaces for fundamental engine operations. ```cpp #include "async/NetworkSystem.h" #include "BuildDefines.h" #include "BuildVersion.h" #include "CmdSystem.h" #include "Common.h" #include "CVarSystem.h" #include "DeclAF.h" // Forward declarations or common utility definitions... ``` -------------------------------- ### Build PAK File from Directory (Python) Source: https://context7.com/id-software/doom-3/llms.txt This script demonstrates how to create a game PAK file (a compressed archive) from a list of game asset files. It utilizes a hypothetical `build_pak` function, specifying the output PAK file name, the source asset directory, and the list of files to include. ```python files_to_pack = [ 'models/custom/weapon.lwo', 'textures/custom/metal.tga', 'scripts/custom_weapons.def', 'sounds/custom/fire.ogg' ] build_pak( pak='mods/mymod/pak000.pk4', path='/path/to/mymod/assets', files=files_to_pack ) ``` -------------------------------- ### Get Available Proxy Authentication Methods Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_getinfo.html Retrieves a bitmask indicating the HTTP authentication methods available for the proxy. ```APIDOC ## GET /id-software/doom-3/proxy-auth-avail ### Description Retrieves a bitmask indicating the available HTTP authentication methods for the proxy. ### Method GET ### Endpoint /id-software/doom-3/proxy-auth-avail ### Parameters #### Query Parameters - **proxyAuthAvailPtr** (long*) - Required - A pointer to a long to receive a bitmask of available proxy authentication methods. ### Response #### Success Response (200) - **proxyAuthMethods** (integer) - A bitmask representing the available proxy HTTP authentication methods. #### Response Example ```json { "proxyAuthMethods": 2 } ``` ``` -------------------------------- ### Get Available HTTP Authentication Methods Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_getinfo.html Retrieves a bitmask indicating the HTTP authentication methods available for the server. ```APIDOC ## GET /id-software/doom-3/http-auth-avail ### Description Retrieves a bitmask indicating the available HTTP authentication methods for the server. ### Method GET ### Endpoint /id-software/doom-3/http-auth-avail ### Parameters #### Query Parameters - **authAvailPtr** (long*) - Required - A pointer to a long to receive a bitmask of available authentication methods. ### Response #### Success Response (200) - **authMethods** (integer) - A bitmask representing the available HTTP authentication methods. Refer to CURLOPT_HTTPAUTH documentation for bit meanings. #### Response Example ```json { "authMethods": 4 } ``` ``` -------------------------------- ### Initialize libcurl Easy Session (C) Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_init.html This C code snippet demonstrates the initialization of a libcurl easy session using curl_easy_init. This function must be called first and requires a corresponding call to curl_easy_cleanup. It returns a CURL easy handle used for other libcurl easy functions. ```c #include CURL *curl_handle = curl_easy_init(); if (curl_handle == NULL) { // Handle initialization error fprintf(stderr, "Error initializing curl easy session.\n"); return 1; } // Use curl_handle for other curl operations... curl_easy_cleanup(curl_handle); ``` -------------------------------- ### HTTP Request Method and Version Control Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_setopt.html Options to force HTTP GET requests and control the HTTP protocol version used. ```APIDOC ## CURL *HTTPGET* ### Description Forces the HTTP request to use the GET method. Primarily useful when a POST, PUT, or custom request has been made previously with the same curl handle. ### Method setopt(CURLOPT_HTTPGET, 1) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); ``` ### Response #### Success Response (200) Not Applicable #### Response Example Not Applicable ## CURL *HTTP_VERSION* ### Description Forces libcurl to use a specific HTTP version. Use with caution and only when necessary. ### Method setopt(CURLOPT_HTTP_VERSION, ) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c // Enforce HTTP 1.1 curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); ``` ### Response #### Success Response (200) Not Applicable #### Response Example Not Applicable ``` -------------------------------- ### Rendering System - Entity and Light Management Source: https://context7.com/id-software/doom-3/llms.txt Handles 3D rendering using an OpenGL-based renderer, supporting dynamic entities, lights, and materials. Allows for the creation, manipulation, and rendering of scene elements. ```APIDOC ## Rendering System - Entity and Light Management ### Description Manages the 3D rendering pipeline, including the definition and manipulation of entities, lights, and camera views. Utilizes an OpenGL-based renderer. ### Core Components - `idRenderSystem`: The main interface for rendering operations. - `idRenderWorld`: Represents a single rendering scene or world. - `renderEntity_t`: Structure defining a renderable entity. - `renderLight_t`: Structure defining a light source. - `renderView_t`: Structure defining the camera's perspective and rendering parameters. ### Key Functions - `renderSystem->AllocRenderWorld()`: Allocates a new render world. - `renderWorld->AddEntityDef(entity)`: Adds an entity definition to the render world. - `renderWorld->UpdateEntityDef(handle, entity)`: Updates an existing entity's definition. - `renderWorld->FreeEntityDef(handle)`: Removes an entity from the render world. - `renderWorld->AddLightDef(light)`: Adds a light definition to the render world. - `renderWorld->FreeLightDef(handle)`: Removes a light from the render world. - `renderWorld->RenderScene(view)`: Renders the scene based on the provided view parameters. - `renderSystem->FreeRenderWorld(renderWorld)`: Frees a previously allocated render world. ### Example Usage ```cpp // Allocate a render world idRenderWorld *renderWorld = renderSystem->AllocRenderWorld(); // Define and add an entity renderEntity_t entity; // ... initialize entity properties (hModel, origin, axis, etc.) ... qhandle_t entityHandle = renderWorld->AddEntityDef(&entity); // Define and add a light renderLight_t light; // ... initialize light properties (origin, lightRadius, shader, etc.) ... qhandle_t lightHandle = renderWorld->AddLightDef(&light); // Define the camera view renderView_t view; // ... initialize view properties (vieworg, viewaxis, fov, width, height, etc.) ... // Render the scene renderWorld->RenderScene(&view); // Cleanup renderWorld->FreeLightDef(lightHandle); renderWorld->FreeEntityDef(entityHandle); renderSystem->FreeRenderWorld(renderWorld); ``` ``` -------------------------------- ### Cookie Management Options Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_setopt.html Options related to managing cookies, including writing cookies to a file and starting a new cookie session. ```APIDOC ## CURL *COOKIJAR* ### Description Writes all internally known cookies to the specified file when curl_easy_cleanup() is called. If no cookies are known, no file will be created. Specify "-" to write cookies to stdout. Enables cookies for the session, affecting subsequent requests like redirects. ### Method setopt(CURLOPT_COOKIEJAR, "") ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c curl_easy_setopt(curl, CURLOPT_COOKIEJAR, "cookies.txt"); ``` ### Response #### Success Response (200) Not Applicable #### Response Example Not Applicable ## CURL *COOKIESESSION* ### Description Marks the current cookie handling as a new session. Forces libcurl to ignore session cookies from the previous session. By default, libcurl stores and loads all cookies, regardless of expiry. ### Method setopt(CURLOPT_COOKIESESSION, 1) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c curl_easy_setopt(curl, CURLOPT_COOKIESESSION, 1L); ``` ### Response #### Success Response (200) Not Applicable #### Response Example Not Applicable ``` -------------------------------- ### Get libcurl compiler used Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl-config.html This command displays the name of the compiler that was used to build libcurl. This information can be useful for compatibility checks or build environment verification. ```shell curl-config --cc ``` -------------------------------- ### Doom 3 Engine Main Entry Point and Game Loop (C++) Source: https://context7.com/id-software/doom-3/llms.txt The main entry point and game loop for the Doom 3 engine, typically found in platform-specific files like `neo/sys/linux/main.cpp`. It handles platform-specific initialization, engine initialization, and enters a continuous loop for game updates and rendering. It also includes an asynchronous thread for lower-frequency updates. ```cpp // neo/sys/linux/main.cpp #include "framework/Common.h" int main(int argc, const char **argv) { // Platform-specific early initialization Posix_EarlyInit(); // Initialize the engine if (common->Init(argc, argv, NULL)) { // Main game loop - runs at display refresh rate while (1) { // Update game state, render frame, process input common->Frame(); } } // Platform-specific late initialization for features Posix_LateInit(); return 0; } // Async thread for 60Hz updates (input, sound mixing) void *Sys_AsyncThread(void *param) { int now = 0; int next = 0; while (1) { pthread_mutex_lock(&async_mutex); next += 16; // ~60Hz (16ms per frame) now = Sys_Milliseconds(); if (next < now) { next = now; } // Call engine async update common->Async(); pthread_mutex_unlock(&async_mutex); // Sleep until next frame usleep((next - now) * 1000); } } ``` -------------------------------- ### libcurl Error Codes Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/libcurl-errors.html This section lists and explains the various error codes returned by libcurl functions. It's recommended to use CURLOPT_ERRORBUFFER to get human-readable error strings for more detailed diagnostics. ```APIDOC ## libcurl Error Codes This document details the error codes returned by libcurl functions. Using `CURLOPT_ERRORBUFFER` is advised for more descriptive error messages. ### CURLcode Enumeration Almost all "easy" interface functions return a `CURLcode` error code. #### `CURLE_OK` (0) **Description**: All operations were successful. #### `CURLE_UNSUPPORTED_PROTOCOL` (1) **Description**: The URL specified a protocol that is not supported by this build of libcurl. This could be due to compile-time options, a misspelled protocol, or a protocol libcurl doesn't implement. #### `CURLE_FAILED_INIT` (2) **Description**: An error occurred during the very early stages of libcurl initialization. This typically indicates an internal problem. #### `CURLE_URL_MALFORMAT` (3) **Description**: The provided URL was not properly formatted. #### `CURLE_URL_MALFORMAT_USER` (4) **Description**: The user part of the URL syntax was incorrect. #### `CURLE_COULDNT_RESOLVE_PROXY` (5) **Description**: The specified proxy host could not be resolved. #### `CURLE_COULDNT_RESOLVE_HOST` (6) **Description**: The specified remote host could not be resolved. #### `CURLE_COULDNT_CONNECT` (7) **Description**: Failed to establish a connection to the host or proxy. #### `CURLE_FTP_WEIRD_SERVER_REPLY` (8) **Description**: An unexpected or invalid reply was received from the FTP server after connecting. The server might not be a compliant FTP server. #### `CURLE_FTP_ACCESS_DENIED` (9) **Description**: Access was denied when attempting to log in to an FTP server or change the working directory. #### `CURLE_FTP_USER_PASSWORD_INCORRECT` (10) **Description**: The provided username and/or password for FTP login were incorrect. #### `CURLE_FTP_WEIRD_PASS_REPLY` (11) **Description**: An unexpected reply was received from the FTP server after sending the password. #### `CURLE_FTP_WEIRD_USER_REPLY` (12) **Description**: An unexpected reply was received from the FTP server after sending the username. #### `CURLE_FTP_WEIRD_PASV_REPLY` (13) **Description**: libcurl failed to get a sensible response from the server to a PASV or EPSV command. The FTP server may be misconfigured. #### `CURLE_FTP_WEIRD_227_FORMAT` (14) **Description**: libcurl could not parse the 227 line response from the FTP server to a PASV command. #### `CURLE_FTP_CANT_GET_HOST` (15) **Description**: An internal error occurred while trying to look up the host for a new FTP connection. #### `CURLE_FTP_CANT_RECONNECT` (16) **Description**: An error occurred with the PASV or EPSV command response from the FTP server, preventing libcurl from continuing the connection. #### `CURLE_FTP_COULDNT_SET_BINARY` (17) **Description**: An error occurred while trying to set the FTP transfer mode to binary. #### `CURLE_PARTIAL_FILE` (18) **Description**: The transferred file size did not match the expected size reported by the server. #### `CURLE_FTP_COULDNT_RETR_FILE` (19) **Description**: An issue occurred with the `RETR` command on an FTP server, or a zero-byte transfer was unexpectedly completed. #### `CURLE_FTP_WRITE_ERROR` (20) **Description**: The FTP server did not return a proper success code after a file transfer was completed. #### `CURLE_FTP_QUOTE_ERROR` (21) **Description**: A custom `QUOTE` command sent to the FTP server resulted in an error code of 400 or higher. #### `CURLE_HTTP_RETURNED_ERROR` (22) **Description**: Returned when `CURLOPT_FAILONERROR` is set to `TRUE` and the HTTP server returns an error code of 400 or greater. #### `CURLE_WRITE_ERROR` (23) **Description**: An error occurred while writing received data to a local file, or a write callback function returned an error. #### `CURLE_MALFORMAT_USER` (24) **Description**: The username was badly specified. (Currently not used). #### `CURLE_FTP_COULDNT_STOR_FILE` (25) **Description**: The FTP server denied the `STOR` operation for a file. The error buffer often contains the server's explanation. #### `CURLE_READ_ERROR` (26) **Description**: An error occurred while reading a local file, or a read callback function returned an error. #### `CURLE_OUT_OF_MEMORY` (27) **Description**: A memory allocation request failed. This is a critical error. #### `CURLE_OPERATION_TIMEOUTED` (28) **Description**: The operation timed out as the specified time limit was reached. ``` -------------------------------- ### Display Curl and Libcurl Version Information Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/curl.html Shows detailed version information about the curl executable and the libcurl library it uses, including supported protocols and features like IPv6, SSL, and compression. ```bash curl -V ``` -------------------------------- ### Get Private Data Pointer Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_getinfo.html Retrieves a pointer to the private data associated with the curl handle. This data is set using the CURLOPT_PRIVATE option in curl_easy_setopt. ```APIDOC ## GET /id-software/doom-3/private-data ### Description Retrieves a pointer to private data associated with a curl handle. ### Method GET ### Endpoint /id-software/doom-3/private-data ### Parameters #### Query Parameters - **privateDataPtr** (char**) - Required - A pointer to a char* to receive the pointer to the private data. ### Response #### Success Response (200) - **privateData** (pointer) - A pointer to the private data associated with the curl handle. This value is set using CURLOPT_PRIVATE. #### Response Example ```json { "privateData": "0x7ffc12345678" } ``` ``` -------------------------------- ### Doom 3 Physics: Rigid Body and Player Dynamics Simulation Source: https://context7.com/id-software/doom-3/llms.txt Demonstrates setting up and simulating rigid body physics for entities, including collision, mass, forces, and velocity. It also shows basic player physics initialization with speed and input settings. Requires the idEntity, idPhysics_RigidBody, idPhysics_Player, and related math/clip model classes. ```cpp // neo/game/physics/Physics.h void PhysicsExample(idEntity *entity) { // Create rigid body physics idPhysics_RigidBody *physics = new idPhysics_RigidBody(); physics->SetSelf(entity); // Setup collision model idClipModel *clipModel = new idClipModel( idTraceModel(idBounds(idVec3(-10, -10, -10), idVec3(10, 10, 10))) ); physics->SetClipModel(clipModel, 50.0f); // 50 kg mass // Set physics properties physics->SetMass(50.0f); physics->SetContents(CONTENTS_BODY); physics->SetClipMask(MASK_SOLID); // Position and orientation physics->SetOrigin(idVec3(0, 0, 100)); physics->SetAxis(idAngles(0, 45, 0).ToMat3()); // Set velocity physics->SetLinearVelocity(idVec3(100, 0, 200)); // m/s physics->SetAngularVelocity(idVec3(0, 0, 3.14f)); // rad/s // Apply forces and impulses idVec3 impactPoint(10, 0, 0); idVec3 impulse(0, 0, 500); // Upward impulse physics->ApplyImpulse(0, impactPoint, impulse); idVec3 forcePoint(0, 0, 0); idVec3 force(100, 0, 0); // Continuous force physics->AddForce(0, forcePoint, force); // Simulate physics (called each frame) int timeStepMSec = 16; // 16ms per frame bool moved = physics->Evaluate(timeStepMSec, gameLocal.time); if (moved) { // Get updated position and velocity idVec3 newPos = physics->GetOrigin(); idVec3 velocity = physics->GetLinearVelocity(); idMat3 orientation = physics->GetAxis(); common->Printf("Position: %s, Velocity: %s\n", newPos.ToString(), velocity.ToString()); } // Player physics example (character controller) idPhysics_Player *playerPhysics = new idPhysics_Player(); playerPhysics->SetSpeed(320.0f, 400.0f); // Walk, run speeds playerPhysics->SetDelta(0, 0); // Movement input playerPhysics->SetPlayerInput(usercmd); // User commands } ``` -------------------------------- ### Add ptrname/ptrcontent section using curl_formadd Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_formadd.html This example demonstrates using `CURLFORM_PTRNAME` and `CURLFORM_PTRCONTENTS` with `curl_formadd`. Both the name and content are provided as pointers, allowing for dynamic naming and content. ```c struct HttpPost* post = NULL; struct HttpPost* last = NULL; char namebuffer[] = "name buffer"; long namelength = strlen(namebuffer); char buffer[] = "test buffer"; curl_formadd(&post, &last, CURLFORM_PTRNAME, namebuffer, CURLFORM_PTRCONTENTS, buffer, CURLFORM_NAMELENGTH, namelength, CURLFORM_END); ``` -------------------------------- ### Get Content-Type Source: https://github.com/id-software/doom-3/blob/master/neo/curl/docs/libcurl/curl_easy_getinfo.html Retrieves the content-type of a downloaded object. This is the value read from the Content-Type: field. Returns NULL if the server did not send a valid Content-Type header or if the protocol does not support it. ```APIDOC ## GET /id-software/doom-3/content-type ### Description Retrieves the content-type of a downloaded object from the server. ### Method GET ### Endpoint /id-software/doom-3/content-type ### Parameters #### Query Parameters - **contentTypePtr** (char**) - Required - A pointer to a char* to receive the content-type. ### Response #### Success Response (200) - **contentType** (string) - The content-type of the downloaded object. This field may be NULL if no valid Content-Type header was received or if the protocol does not support it. #### Response Example ```json { "contentType": "application/octet-stream" } ``` ``` -------------------------------- ### C++ File System: Access Native and PAK Archives Source: https://context7.com/id-software/doom-3/llms.txt Illustrates using the `idFileSystem` to list files (including recursive and by extension), check PAK file membership, convert between OS and relative paths, and read/write files. Supports virtual file system abstraction over native filesystem and PAK archives. ```cpp // neo/framework/FileSystem.h extern idFileSystem *fileSystem; void FileSystemExample() { // List all .def files in scripts directory idFileList *defFiles = fileSystem->ListFiles("scripts", ".def", true); for (int i = 0; i < defFiles->GetNumFiles(); i++) { common->Printf("Found: %s\n", defFiles->GetFile(i)); } fileSystem->FreeFileList(defFiles); // Recursive directory tree listing idFileList *allModels = fileSystem->ListFilesTree("models", ".lwo"); for (int i = 0; i < allModels->GetNumFiles(); i++) { common->Printf("Model: %s\n", allModels->GetFile(i)); } fileSystem->FreeFileList(allModels); // Check if file is in PAK if (fileSystem->FileIsInPAK("models/weapons/machinegun.lwo")) { common->Printf("File is packed\n"); } // Path conversions const char *osPath = fileSystem->RelativePathToOSPath( "base/maps/game/mp/d3dm1.map", "fs_game"); common->Printf("OS path: %s\n", osPath); const char *relPath = fileSystem->OSPathToRelativePath( "/home/user/doom3/base/models/test.lwo"); common->Printf("Relative path: %s\n", relPath); // Build complete OS path const char *fullPath = fileSystem->BuildOSPath( cvarSystem->GetCVarString("fs_basepath"), cvarSystem->GetCVarString("fs_game"), "maps/testmap.map"); // Read file idFile *file = fileSystem->OpenFileRead("maps/game/mp/d3dm1.map"); if (file) { int length = file->Length(); char *buffer = new char[length + 1]; file->Read(buffer, length); buffer[length] = '\0'; common->Printf("File size: %d bytes\n", length); delete[] buffer; fileSystem->CloseFile(file); } // Write file idFile *outFile = fileSystem->OpenFileWrite("save/quicksave.dat"); if (outFile) { outFile->WriteString("SaveGame Data\n"); outFile->WriteInt(gameLocal.time); fileSystem->CloseFile(outFile); } } ``` -------------------------------- ### Python Utility: Manage PAK Files and Verify Assets Source: https://context7.com/id-software/doom-3/llms.txt Provides Python functions for interacting with Doom 3's PAK (ZIP archive) system. Includes listing PAK files, listing contents within a PAK, generating MD5 checksums for PAK contents, and identifying updated or missing files between PAK archives and extracted directories. ```python # neo/sys/linux/pk4/id_utils.py import sys sys.path.append('neo/sys/linux/pk4') from id_utils import * # List all PAK files in a directory (sorted reverse alphabetically) pak_files = list_paks('/path/to/doom3/base') for pak in pak_files: print(f"Found PAK: {pak}") # List contents of a specific PAK file files_in_pak = list_files_in_pak('/path/to/doom3/base/pak000.pk4') for file in files_in_pak: print(f" {file}") # Build MD5 dictionary for all files in PAKs pak_md5_dict = md5_in_paks('/path/to/doom3/base') for filename, (pakname, md5hash) in pak_md5_dict.items(): print(f"{filename}: {md5hash} (from {pakname})") # Find updated files between PAKs and extracted directory updated, not_found, case_table = list_updated_files( pak_path='/path/to/doom3/base', base_path='/path/to/extracted/assets', case_match=True ) print(f"Updated files: {len(updated)}") for file in updated: print(f" Modified: {file}") print(f"Not found: {len(not_found)}") for file in not_found: print(f" Missing: {file}") ```