Add MCPI_DEBUG & Improve Documentation
This commit is contained in:
parent
5d8a1e4230
commit
a1f777f632
@ -50,7 +50,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
add_compile_options(-O3)
|
||||
else()
|
||||
add_compile_options(-g)
|
||||
add_definitions(-DDEBUG)
|
||||
endif()
|
||||
|
||||
# Start Project
|
||||
|
@ -1,16 +1,39 @@
|
||||
# Command Line Arguments
|
||||
# Command Line Usage
|
||||
|
||||
## ``--print-available-feature-flags`` (Client Mode Only)
|
||||
If you run MCPI-Reborn with ``--print-available-feature-flags``, it will print the available feature flags and then immediately exit. The feature flags are printed in the following format:
|
||||
## Command Line Arguments
|
||||
|
||||
### ``--print-available-feature-flags`` (Client Mode Only)
|
||||
If you run MCPI-Reborn with ``--print-available-feature-flags``, it will print the available feature flags and then immediately exit.
|
||||
|
||||
The feature flags are printed in the following format:
|
||||
```
|
||||
TRUE This Flag Is On By Default
|
||||
FALSE This Flag Is Off By Default
|
||||
```
|
||||
|
||||
## ``--only-generate`` (Server Mode Only)
|
||||
### ``--only-generate`` (Server Mode Only)
|
||||
If you run MCPI-Reborn with ``--only-generate``, it will immediately exit once world generation has completed. This is mainly used for automatically testing MCPI-Reborn.
|
||||
|
||||
## ``--benchmark`` (Client Mode Only)
|
||||
### ``--benchmark`` (Client Mode Only)
|
||||
If you run MCPI-Reborn with ``--benchmark``, it will enter a simple benchmark mode. This means automatically loading a newly generated world, then rotating the camera for a period of time. When it has finished, it will then exit and print the average FPS while the world was loaded. In this mode, all user input is blocked. However you can still modify rendering settings by changing feature flags.
|
||||
|
||||
The world used will always be re-created on start and uses a hard-coded seed.
|
||||
|
||||
## Environmental Variables
|
||||
|
||||
### ``MCPI_DEBUG``
|
||||
This enables debug logging if you set it to any non-zero-length value.
|
||||
|
||||
### Client Mode Only
|
||||
If a value isn't set for any of the following variables, a GUI will open that allows you to select one.
|
||||
|
||||
### ``MCPI_FEATURE_FLAGS``
|
||||
This corresponds to ``--print-available-feature-flags``. This is just a list of all enabled feature flags separated by ``|``.
|
||||
|
||||
For instance, the string ``Feature A|Feature B`` would enable both ``Feature A`` and ``Feature B`` and *disable every other available feature flag*.
|
||||
|
||||
### ``MCPI_RENDER_DISTANCE``
|
||||
This is the render distance. The possible values are: ``Far``, ``Normal``, ``Short``, and ``Tiny``.
|
||||
|
||||
### ``MCPI_USERNAME``
|
||||
This is the username.
|
||||
|
@ -38,10 +38,9 @@ void set_and_print_env(const char *name, char *value) {
|
||||
trim(&value);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// Print New Value
|
||||
INFO("Set %s = %s", name, value);
|
||||
#endif
|
||||
DEBUG("Set %s = %s", name, value);
|
||||
|
||||
// Set The Value
|
||||
setenv(name, value, 1);
|
||||
}
|
||||
|
@ -6,5 +6,6 @@
|
||||
// Logging
|
||||
#define INFO(format, ...) { fprintf(stderr, "[INFO]: " format "\n", __VA_ARGS__); }
|
||||
#define WARN(format, ...) { fprintf(stderr, "[WARN]: " format "\n", __VA_ARGS__); }
|
||||
#define DEBUG(format, ...) { const char *debug = getenv("MCPI_DEBUG"); if (debug != NULL && strlen(debug) > 0) { fprintf(stderr, "[DEBUG]: " format "\n", __VA_ARGS__); } }
|
||||
#define ERR(format, ...) { fprintf(stderr, "[ERR]: (%s:%i): " format "\n", __FILE__, __LINE__, __VA_ARGS__); exit(EXIT_FAILURE); }
|
||||
#define IMPOSSIBLE() ERR("%s", "This Should Never Be Called")
|
||||
|
@ -79,9 +79,7 @@ static void update_code_block(void *target) {
|
||||
if (code_block == MAP_FAILED) {
|
||||
ERR("Unable To Allocate Code Block: %s", strerror(errno));
|
||||
}
|
||||
#ifdef DEBUG
|
||||
INFO("Code Block Allocated At: 0x%08x", (uint32_t) code_block);
|
||||
#endif
|
||||
DEBUG("Code Block Allocated At: 0x%08x", (uint32_t) code_block);
|
||||
}
|
||||
if (code_block_remaining < CODE_SIZE) {
|
||||
ERR("%s", "Maximum Amount Of overwrite_calls() Uses Reached");
|
||||
@ -138,11 +136,7 @@ void _overwrite(const char *file, int line, void *start, void *target) {
|
||||
}
|
||||
|
||||
// Print Patch Debug Data
|
||||
#ifdef DEBUG
|
||||
#define PATCH_PRINTF(file, line, start, str) if (file != NULL) fprintf(stderr, "[PATCH]: (%s:%i) Patching (0x%08x) - "str": 0x%02x 0x%02x 0x%02x 0x%02x\n", file, line, (uint32_t) start, data[0], data[1], data[2], data[3]);
|
||||
#else
|
||||
#define PATCH_PRINTF(file, line, start, str) { (void) file; (void) line; (void) start; (void) str; } // Mark As Used
|
||||
#endif
|
||||
#define PATCH_PRINTF(file, line, start, str) if (file != NULL) DEBUG("(%s:%i): Patching (0x%08x) - " str ": 0x%02x 0x%02x 0x%02x 0x%02x", file, line, (uint32_t) start, data[0], data[1], data[2], data[3]);
|
||||
|
||||
// Patch Instruction
|
||||
void _patch(const char *file, int line, void *start, unsigned char patch[4]) {
|
||||
|
@ -29,8 +29,10 @@ int feature_has(const char *name, int server_default) {
|
||||
tok = strtok(NULL, "|");
|
||||
}
|
||||
free(features);
|
||||
#ifdef DEBUG
|
||||
INFO("Feature: %s: %s", name, ret ? "Enabled" : "Disabled");
|
||||
#endif
|
||||
|
||||
// Log
|
||||
DEBUG("Feature: %s: %s", name, ret ? "Enabled" : "Disabled");
|
||||
|
||||
// Return
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user