### Compile Wolfpack on Debian
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
Instructions for compiling the Wolfpack project on a Debian system. This involves installing necessary QT4 and Python packages, and then running the compilation script. It also mentions optional CXXFLAGS and compiling boost separately.
```bash
tar xvfj wolfpack.tar.bz2 -C ./
cd wolfpack_source_dir/build/
chmod +x configure.py
./configure.py --help
# Please read the options and use those that apply to you.
# Running configure.py should auto detect most options.
./configure.py --enable-debug --enable-mysql
# At this point you can edit Makefile and add optional CXXFLAGS
# I personally add -march=athlon -03
# Before we can run make now, we have to compile boost
cd ../boost
qmake
make
# Get yourself a coffee while it compiles.
# Go back to wolfpack build folder.
cd ../build
make
# Grab a snack while it compiles.
```
--------------------------------
### Compile Client with Visual Studio (qmake)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/Compile Instructions.txt
This command initiates the build process for the client using qmake in conjunction with Visual Studio. It generates a .vcproj file that can be opened directly in the Visual Studio IDE for further compilation and development.
```bash
qmake -tp vc
```
--------------------------------
### Compile Client with QMake (General)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/Compile Instructions.txt
This command uses qmake to prepare the project for compilation across various platforms. After running qmake, a platform-specific build command like 'nmake' or 'make' should be executed to complete the client compilation.
```bash
qmake
nmake
```
--------------------------------
### Configure Ultima Online Login Server
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
This configuration snippet shows how to set up the 'login.cfg' file in your Ultima Online installation directory. It specifies the login server address and port, which is crucial for connecting to a Wolfpack server. Ensure you use your actual IP address.
```cfg
;Loginservers for Ultima Online
;Do not edit this file or patching will fail! Always save a backup.
;LoginServer=login.owo.com,7775
;LoginServer=login.owo.com,7776
;PLEASE NOTE THAT 192.168.1.100 IS AN EXAMPLE OF YOUR IP!
LoginServer=192.168.1.100,2593
```
--------------------------------
### Configure Wolfpack Options in XML
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
This snippet demonstrates how to configure various options for the Wolfpack project by editing the wolfpack.xml file. It shows examples for LoginServer and Network settings, including IP addresses, ports, and boolean flags. These settings control server behavior and network connectivity.
```xml
```
--------------------------------
### RAM Compression/Decompression Example (LZMA + BCJ)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/history.txt
Introduces new example files for RAM-to-RAM compression and decompression using LZMA with the BCJ filter for x86 code. This includes header and source files for both compression and decompression, along with a command-line switch for the lzma.exe utility.
```c
/* Version 4.17 */
/* New example for RAM->RAM compressing/decompressing: LZMA + BCJ (filter for x86 code): */
/* LzmaRam.h, LzmaRam.cpp, LzmaRamDecode.h, LzmaRamDecode.c */
/* -f86 switch for lzma.exe */
```
--------------------------------
### 7-Zip Archive Creation Command (Windows Batch)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zC.txt
Example command to create a .7z archive using 7za.exe. It demonstrates adding files recursively, setting compression level, and optionally configuring solid block size for faster extraction of large archives.
```batch
7za.exe a archive.7z *.htm -r -mx -m0fb=255
# Example with partly-solid archive for faster extraction:
7za.exe a archive.7z *.htm -ms=512K -r -mx -m0fb=255 -m0d=512K
```
--------------------------------
### Item and World Object Management (C++)
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Provides C++ code examples for creating items, setting their properties like amount and price, moving them, managing them within containers, and equipping them. It also shows how to retrieve item properties and manage vendor stock.
```cpp
// Item creation from definitions
cItem* item = Items::instance()->createItem("gold_coins");
item->setAmount(1000);
item->moveTo(Coord(1500, 1500, 0, 0));
// Container and inventory management
P_CHAR player = socket->player();
cItem* backpack = player->getItemOnLayer(cBaseChar::Backpack);
if (backpack) {
// Add item to container
item->setContainer(backpack);
backpack->addItem(item, false); // false = don't stack
// Find items in container
ItemContainer items = backpack->getItems();
for (ItemContainer::iterator it = items.begin(); it != items.end(); ++it) {
cItem* containerItem = it.value();
if (containerItem->id() == 0xEED) { // Gold coin ID
totalGold += containerItem->amount();
}
}
}
// Equipment layer management
cItem* weapon = player->getItemOnLayer(cBaseChar::RightHand);
if (weapon) {
int damage = rollDice(weapon->getTag("damage").toString());
target->damage(damage);
}
// Item properties and tags
item->setTag("magic_power", 50);
item->setTag("blessed", 1);
int power = item->getTag("magic_power").toInt();
// Vendor shop items with restock
cItem* shopItem = Items::instance()->createItem("longsword");
shopItem->setBuyPrice(100);
shopItem->setSellPrice(75);
shopItem->setRestock(10); // Restocks to 10 items
shopItem->setAmount(5); // Current stock
```
--------------------------------
### List Contents of 7z Archive (C)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zC.txt
Provides a code example for iterating through the database of an opened 7z archive and printing the size and name of each file. This functionality is useful for inspecting archive contents without extraction.
```c
{
UInt32 i;
for (i = 0; i < db.Database.NumFiles; i++)
{
CFileItem *f = db.Database.Files + i;
printf("%10d %s\n", (int)f->Size, f->Name);
}
}
```
--------------------------------
### 7z Decoder Test Application Usage (Command Line)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zC.txt
Shows the command-line syntax for the 7z ANSI-C Decoder test application. It outlines the available commands (e for extract, l for list, t for test) and provides examples for listing and extracting archive contents.
```shell
Usage: 7zDec :
e: Extract files from archive
l: List contents of archive
t: Test integrity of archive
Example:
7zDec l archive.7z
lists contents of archive.7z
7zDec e archive.7z
extracts files from archive.7z to current folder.
```
--------------------------------
### Game Data Retrieval (Python)
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Demonstrates how to retrieve information about ores, NPCs, and item colors using predefined dictionaries or get methods. Assumes the existence of ORES, NPCS, NPCAI, and COLORS objects.
```python
ore_info = ORES.get('I_ORE_MYTHERIL') # Returns ['agapite', 0x979]
npc_name = NPCS.get('C_ZOMBIE') # Returns 'zombie'
pc_ai = NPCAI.get(10) # Returns 'Monster_Aggressive_L1'
color_info = COLORS.get(0x52D) # Returns ['agapite', 0x979]
```
--------------------------------
### WPGM Data Structures and Usage (Delphi)
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Defines data structures for locations and NPCs within the World and Polygon Gump Map Editor (WPGM) and provides example procedures for adding travel locations, exporting regions, and rendering maps using UO files. Relies on various components like virtual tree views, map displays, and data readers.
```delphi
// Main WPGM data structures
type TLocationNode = record
Id: Cardinal;
Name: WideString;
LocId: String;
PosX: Cardinal;
PosY: Cardinal;
PosZ: ShortInt;
PosMap: Byte;
end;
type TNpcNode = record
Id: Cardinal;
Name: WideString;
BodyId: Word;
Skin: Word;
AddId: String;
Equipment: Array of TNpcEquipment;
end;
// Example usage in Delphi application
procedure TfrmMain.AddTravelLocation(x, y, z: Integer; mapId: Byte; name: String);
var
node: PLocationNode;
begin
New(node);
node^.Id := GetNextLocationId();
node^.Name := name;
node^.LocId := GenerateLocId();
node^.PosX := x;
node^.PosY := y;
node^.PosZ := z;
node^.PosMap := mapId;
// Add to virtual tree view
vtLocItems.AddChild(nil, node);
// Update map display
pbMap.Invalidate;
end;
// Region export to clipboard
procedure TfrmMain.ExportRegion(regionId: Cardinal);
var
regionData: String;
begin
regionData := '[REGION ' + IntToStr(regionId) + ']' + #13#10;
regionData := regionData + 'NAME=' + GetRegionName(regionId) + #13#10;
regionData := regionData + 'P=' + GetRegionPolygon(regionId) + #13#10;
Clipboard.AsText := regionData;
ShowMessage('Region exported to clipboard');
end;
// Map rendering with UO files
procedure TfrmMain.RenderMap(x, y, width, height: Integer);
begin
// Load map data from map*.mul files
for py := y to y + height do
for px := x to x + width do
begin
tileId := MapReader.GetLandTile(px, py);
DrawTile(px - x, py - y, tileId);
// Draw statics on top
statics := StaticsReader.GetStatics(px, py);
for i := 0 to Length(statics) - 1 do
DrawStatic(px - x, py - y, statics[i]);
end;
end;
```
--------------------------------
### Krrios TileData.mul Special Quantity/Quality Interpretations
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/formats/tiledata.html
Details specific interpretations of the 'Quantity' and 'Quality' fields within static entries based on certain flags. For example, if 'Weapon' flag is set, 'Quantity' refers to Weapon Class.
```text
If Weapon, Quantity is Weapon Class.
If Armor, Quantity is Armor Class.
If Wearable, Quality is Layer.
If Light Source, Quality is LightID.
If Container, Height is "Contains" (Something determining how much the container can hold?)
```
--------------------------------
### Compile Python with UCS2 Unicode Support
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
Steps to manually compile Python 2.3.x or 2.4.x with UCS2 Unicode support, a requirement for older Wolfpack versions to avoid unicode errors. This involves downloading Python, configuring with specific options, compiling, and installing.
```bash
# Compiling/Installing Python-2.3.x or Python-2.4.x
tar xvjf Python-2.3.5.tar.bz2 -C ./
cd python_source_dir/
# Please note the --enable-shared and --enable-unicode=ucs2
./configure --prefix=/usr/local --enable-unicode=ucs2 --enable-shared
make
su root
make install
exit
```
--------------------------------
### Configure Definitions Index File in wolfpack.xml
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
This snippet shows how to configure the master index file for definition (.xml) files within the wolfpack.xml configuration. It demonstrates specifying the path to the main index file and allows for the inclusion of custom definition paths.
```xml
```
--------------------------------
### Initialize LZMA Decoder Properties
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/lzma.txt
Initializes the LZMA decoder with provided properties. Returns an error if properties are incorrect. Requires LZMA_PROPERTIES_SIZE.
```c
CLzmaDecoderState state;
if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
return PrintError(rs, "Incorrect stream properties");
```
--------------------------------
### Initialize and Open 7z Archive (C)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zC.txt
Demonstrates the steps to initialize CRC tables, archive database structures, and open a 7z archive using the provided interfaces. It requires custom memory allocation functions for main and temporary pools.
```c
/* 1) Declare variables:
inStream // implements ISzInStream interface
CArchiveDatabaseEx db; // 7z archive database structure
ISzAlloc allocImp; // memory functions for main pool
ISzAlloc allocTempImp; // memory functions for temporary pool */
/* 2) call InitCrcTable(); function to initialize CRC structures. */
InitCrcTable();
/* 3) call SzArDbExInit(&db); function to initialize db structures. */
SzArDbExInit(&db);
/* 4) call SzArchiveOpen(inStream, &db, &allocMain, &allocTemp) to open archive
This function opens archive "inStream" and reads headers to "db".
All items in "db" will be allocated with "allocMain" functions.
SzArchiveOpen function allocates and frees temporary structures by "allocTemp" functions. */
SzArchiveOpen(inStream, &db, &allocMain, &allocTemp);
```
--------------------------------
### Compile Wolfpack on BSD
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
Instructions for compiling the Wolfpack project on a BSD system. The process is similar to Debian, involving unpacking, configuring, and compiling, with a note about optional CXXFLAGS.
```bash
tar xvfj wolfpack.tar.bz2 -C ./
cd wolfpack_source_dir/build/
chmod +x configure.py
./configure.py --help
# Please read the options and use those that apply to you.
# Running configure.py should auto detect most options.
./configure.py --enable-debug --enable-mysql
# At this point you can edit Makefile and add optional CXXFLAGS
# I, Dreoth, personally add -march=athlon -03
make
# Grab a snack while it compiles.
```
--------------------------------
### AnimData.mul Entry Structure
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/formats/animdata.html
Details the structure of an individual entry within an AnimData.mul block. It contains frame data, an unknown byte, frame count, frame interval, and frame start delay. Note that frameData may be less than 64 bytes.
```c++
struct AnimDataEntry {
sbyte frameData[64]; // May contain garbage data
byte unknown;
byte frameCount;
byte frameInterval; // Delay between frames in 50ms increments
byte frameStart; // Initial delay before animation starts in 50ms increments
};
```
--------------------------------
### C++ Binary Data Serialization and Byte Swapping
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Implements efficient buffered binary serialization for writing various data types (integers, shorts, bytes, booleans, strings) to a file. It automatically handles endianness conversion for network transmission using `swapBytes` utility. Requires `QString` and `QByteArray` for string handling.
```cpp
// Buffered writer for efficient serialization (1MB buffer)
cBufferedWriter writer("worldsave.dat");
// Write various data types (automatically handles endianness)
writer.writeInt(0x12345678); // 4 bytes
writer.writeShort(0x1234); // 2 bytes
writer.writeByte(0xFF); // 1 byte
writer.writeBool(true); // 1 byte (0 or 1)
// String encoding
writer.writeUtf8(QString("Player Name")); // UTF-8 encoded with length prefix
writer.writeAscii(QByteArray("DATA")); // Raw ASCII bytes
// Byte swapping utilities for network byte order
unsigned int networkData = 0x12345678;
swapBytes(networkData); // Convert between little/big endian
// Result: 0x78563412
unsigned short portNumber = 2593;
swapBytes(portNumber); // Works with shorts, ints, doubles
socket->send(portNumber);
// Double precision swapping for floating point data
double value = 123.456;
swapBytes(value); // Swaps all 8 bytes for network transmission
```
--------------------------------
### Multi-Call State Decompressing (zlib-like)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/lzma.txt
Implements a zlib-like interface for multi-call LZMA decompression, suitable for file-to-file operations. It requires managing input and output buffers, initializing the decoder, and handling the decoding process within a loop, potentially with a finish decoding flag.
```c
state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
LzmaDecoderInit(&state);
do
{
res = LzmaDecode(&state,
inBuffer, inAvail, &inProcessed,
g_OutBuffer, outAvail, &outProcessed,
finishDecoding);
inAvail -= inProcessed;
inBuffer += inProcessed;
}
while you need more bytes
```
--------------------------------
### Configure Wolfpack Server XML Settings
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
This XML configuration for 'wolfpack.xml' defines server settings, including login server shard details and network options. It allows customization of shard names, IP addresses, ports, and network behaviors like allowing unencrypted clients. This is essential for setting up your Wolfpack server.
```xml
```
--------------------------------
### Command Processing and ACL in C++
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Implements a command system for server administration, featuring ACL-based permission checks and argument parsing. It allows for registering custom command handlers and processing commands from sockets, ensuring only authorized users can execute specific actions.
```cpp
// Registering a custom command handler
void customCommand(cUOSocket* socket, const QString& command, const QStringList& arguments) {
P_PLAYER player = socket->player();
if (!player) return;
if (arguments.size() < 2) {
socket->sysMessage("Usage: " + command + " ");
return;
}
QString arg1 = arguments[0];
int arg2 = arguments[1].toInt();
socket->sysMessage(QString("Command executed with %1 and %2").arg(arg1).arg(arg2));
}
// Command dispatch
Commands::instance()->process(socket, ".customcmd arg1 123");
// ACL permission checking
cAcl* acl = account->acl();
if (acl && acl->groups.contains("server")) {
if (acl->groups["server"].value("shutdown", false)) {
// User has permission to shutdown server
}
}
// Define ACL structure
cAcl* playerAcl = new cAcl();
playerAcl->name = "player";
playerAcl->rank = 1;
playerAcl->groups["basic"]["say"] = true;
playerAcl->groups["basic"]["tele"] = false;
```
--------------------------------
### Character System (BaseChar) in C++
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Provides the base functionality for characters, including attributes, equipment, combat, and movement. It supports creating characters, managing items equipped in different layers, handling damage, and implementing NPC-specific AI behaviors.
```cpp
// Character creation and basic properties
P_CHAR character = new cBaseChar();
character->setSerial(World::instance()->findCharSerial());
character->setName("Guard");
character->setBody(0x190); // Human male body
character->moveTo(Coord(1000, 1000, 0, 0)); // x, y, z, map
// Equipment management using layers
cItem* sword = Items::instance()->createItem("longsword");
if (character->canPickup(sword)) {
character->addItem(cBaseChar::RightHand, sword); // Layer system
}
// Equipment layers enum values:
// TradeWindow=0, OneHanded=1, LeftHand=2, Shoes=3, Pants=4, Shirt=5
// Helm=6, Gloves=7, Ring=8, Neck=10, Hair=11, Waist=12, InnerTorso=13
// Bracelet=14, FacialHair=16, MiddleTorso=17, Earrings=18, Arms=19
// Cloak=20, Backpack=21, OuterTorso=22, OuterLegs=23, InnerLegs=24
// Stat management
character->setStrength(100);
character->setDexterity(80);
character->setIntelligence(50);
character->setMaxHitpoints(100);
character->setHitpoints(100);
// Combat and damage
character->damage(20); // Deal 20 damage
if (character->isDead()) {
character->kill(); // Handle death
}
// NPC-specific functionality
if (character->isNpc()) {
character->setWanderType(2); // Set AI wander behavior
character->talk("Greetings, traveler!");
}
```
--------------------------------
### Command Processing System
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
APIs for handling in-game commands, including registration of custom commands, ACL-based permission checking, and argument parsing.
```APIDOC
## Command Processing System
### Description
Manages the execution of in-game commands, allowing for the registration of custom command handlers, permission verification via Access Control Lists (ACLs), and parsing of command arguments.
### Method
N/A (C++ Class Methods)
### Endpoint
N/A
### Parameters
N/A
### Request Example
```cpp
// Registering a custom command handler
void customCommand(cUOSocket* socket, const QString& command, const QStringList& arguments) {
P_PLAYER player = socket->player();
if (!player) return;
if (arguments.size() < 2) {
socket->sysMessage("Usage: " + command + " ");
return;
}
QString arg1 = arguments[0];
int arg2 = arguments[1].toInt();
socket->sysMessage(QString("Command executed with %1 and %2").arg(arg1).arg(arg2));
}
// Command dispatch
Commands::instance()->process(socket, ".customcmd arg1 123");
// ACL permission checking
cAcl* acl = account->acl();
if (acl && acl->groups.contains("server")) {
if (acl->groups["server"].value("shutdown", false)) {
// User has permission to shutdown server
}
}
// Define ACL structure
cAcl* playerAcl = new cAcl();
playerAcl->name = "player";
playerAcl->rank = 1;
playerAcl->groups["basic"]["say"] = true;
playerAcl->groups["basic"]["tele"] = false;
```
### Response
N/A (C++ method return values and side effects)
### Response Example
N/A
```
--------------------------------
### Account Management in C++
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Handles user authentication, character slot allocation, ACL-based permissions, and account flag management. It allows for account creation, modification, and retrieval, as well as character slot management and authentication status checks.
```cpp
// Account creation and management
cAccount* account = Accounts::instance()->getAccount("username");
if (!account) {
account = Accounts::instance()->createAccount("username", "password");
account->setCharSlots(5);
account->setAcl(Commands::instance()->getACL("player"));
account->setEmail("user@example.com");
}
// Account flag management (blocking, staff privileges, etc.)
// Flags: 0x01=blocked, 0x02=allmove, 0x04=allshow, 0x08=showserials
// 0x10=pagenotify, 0x20=staff/GM mode, 0x40=multigems, 0x80=jailed, 0x100=young
account->setFlags(account->flags() | 0x20); // Enable staff/GM mode
// Character management
P_PLAYER character = account->getCharacter(0);
if (character) {
account->removeCharacter(character);
}
// Authentication
if (account->inUse()) {
socket->sysMessage("Account already in use");
} else if (account->isBlocked()) {
socket->sysMessage("Account is blocked");
} else {
account->setInUse(true);
account->setLastLogin(QDateTime::currentDateTime());
}
```
--------------------------------
### Account Management System
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
APIs for managing user accounts, including creation, authentication, character slots, permissions, and account flags.
```APIDOC
## Account Management System
### Description
Provides functionality for managing user accounts, including authentication, character slot allocation, permission settings, and account status flags.
### Method
N/A (C++ Class Methods)
### Endpoint
N/A
### Parameters
N/A
### Request Example
```cpp
// Account creation and management
cAccount* account = Accounts::instance()->getAccount("username");
if (!account) {
account = Accounts::instance()->createAccount("username", "password");
account->setCharSlots(5);
account->setAcl(Commands::instance()->getACL("player"));
account->setEmail("user@example.com");
}
// Account flag management (blocking, staff privileges, etc.)
// Flags: 0x01=blocked, 0x02=allmove, 0x04=allshow, 0x08=showserials
// 0x10=pagenotify, 0x20=staff/GM mode, 0x40=multigems, 0x80=jailed, 0x100=young
account->setFlags(account->flags() | 0x20); // Enable staff/GM mode
// Character management
P_PLAYER character = account->getCharacter(0);
if (character) {
account->removeCharacter(character);
}
// Authentication
if (account->inUse()) {
socket->sysMessage("Account already in use");
} else if (account->isBlocked()) {
socket->sysMessage("Account is blocked");
} else {
account->setInUse(true);
account->setLastLogin(QDateTime::currentDateTime());
}
```
### Response
N/A (C++ method return values and side effects)
### Response Example
N/A
```
--------------------------------
### Configure Python Search Path in wolfpack.xml
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/FAQ.html
This snippet illustrates how to set the 'Python Searchpath' option in the wolfpack.xml configuration. This is crucial for managing Python script files (.py) by defining directories where Wolfpack should look for imported scripts.
```xml
```
--------------------------------
### Multi-Call LZMA Decompression with Input Callback and Output Buffer (File to File)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/lzma.txt
Decompresses LZMA data from a file to another file using multi-call processing with input and output buffers. This method requires both input and output stream callbacks to be configured and the decoder to be initialized.
```c
state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
LzmaDecoderInit(&state);
do
{
LzmaDecode(&state,
&bo.InCallback,
g_OutBuffer, outAvail, &outProcessed);
}
while you need more bytes
```
--------------------------------
### LZMA Preprocessor Defines for Input/Output and Optimizations
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/lzma.txt
This snippet shows preprocessor defines used to control LZMA decoder behavior. _LZMA_IN_CB enables callback functions for input data, and _LZMA_OUT_READ specifies using a read function for output. _LZMA_LOC_OPT enables local speed optimizations specific to LzmaDecodeSize.c.
```c
#define _LZMA_IN_CB
#define _LZMA_OUT_READ
#define _LZMA_LOC_OPT
```
--------------------------------
### Character System (BaseChar)
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
APIs related to the base character class, covering core functionalities for both players and NPCs, including combat, equipment management, and attributes.
```APIDOC
## Character System (BaseChar)
### Description
Defines the base functionality for all characters (players and NPCs), including managing attributes, health, movement, equipment, and basic combat interactions.
### Method
N/A (C++ Class Methods)
### Endpoint
N/A
### Parameters
N/A
### Request Example
```cpp
// Character creation and basic properties
P_CHAR character = new cBaseChar();
character->setSerial(World::instance()->findCharSerial());
character->setName("Guard");
character->setBody(0x190); // Human male body
character->moveTo(Coord(1000, 1000, 0, 0)); // x, y, z, map
// Equipment management using layers
cItem* sword = Items::instance()->createItem("longsword");
if (character->canPickup(sword)) {
character->addItem(cBaseChar::RightHand, sword); // Layer system
}
// Equipment layers enum values:
// TradeWindow=0, OneHanded=1, LeftHand=2, Shoes=3, Pants=4, Shirt=5
// Helm=6, Gloves=7, Ring=8, Neck=10, Hair=11, Waist=12, InnerTorso=13
// Bracelet=14, FacialHair=16, MiddleTorso=17, Earrings=18, Arms=19
// Cloak=20, Backpack=21, OuterTorso=22, OuterLegs=23, InnerLegs=24
// Stat management
character->setStrength(100);
character->setDexterity(80);
character->setIntelligence(50);
character->setMaxHitpoints(100);
character->setHitpoints(100);
// Combat and damage
character->damage(20); // Deal 20 damage
if (character->isDead()) {
character->kill(); // Handle death
}
// NPC-specific functionality
if (character->isNpc()) {
character->setWanderType(2); // Set AI wander behavior
character->talk("Greetings, traveler!");
}
```
### Response
N/A (C++ method return values and side effects)
### Response Example
N/A
```
--------------------------------
### LZMA Decompression with Input Stream Callback (File to RAM)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/lzma.txt
Decompresses LZMA data from a file into RAM using an input stream callback. Requires an ILzmaInCallback structure, a file pointer, and a buffer for reading. The decompression is initiated via LzmaDecode.
```c
typedef struct _CBuffer
{
ILzmaInCallback InCallback;
FILE *File;
unsigned char Buffer[kInBufferSize];
} CBuffer;
int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size)
{
CBuffer *bo = (CBuffer *)object;
*buffer = bo->Buffer;
*size = MyReadFile(bo->File, bo->Buffer, kInBufferSize);
return LZMA_RESULT_OK;
}
CBuffer g_InBuffer;
g_InBuffer.File = inFile;
g_InBuffer.InCallback.Read = LzmaReadCompressed;
int res = LzmaDecode(&state,
&g_InBuffer.InCallback,
outStream, outSize, &outProcessed);
```
--------------------------------
### C++ LZMA Encoder Size Optimization
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/lzma.txt
Demonstrates how to reduce the size of the C++ LZMA compressing code by defining specific match finders. By default, the encoder includes all match finders; however, defining COMPRESS_MF_BT and COMPRESS_MF_BT4 limits the encoder to use only the 'bt4' match finder, thus reducing compiled code size.
```cpp
#define COMPRESS_MF_BT
#define COMPRESS_MF_BT4
```
--------------------------------
### Handle Network Packets and Client Connections in C++
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Handles incoming network packets, sending system messages and custom packets to clients. Also manages client connection and disconnection events, updating player and account states.
```cpp
// Socket message and packet handling
void handlePacket(cUOSocket* socket, cUORxPacket* packet) {
// System messages to client
socket->sysMessage("Welcome to the server");
socket->sysMessage(0x35, "Colored message (green)"); // With hue
// Send custom packets
cUOTxPacket response;
response.writeByte(0x1C); // Packet ID
response.writeInt(socket->player()->serial());
response.writeShort(socket->player()->body());
socket->send(&response);
// Error handling
if (!socket->player()) {
socket->sysMessage("You must be logged in");
return;
}
// Check player state
if (socket->player()->isDead()) {
socket->sysMessage("You cannot do that while dead");
return;
}
}
// Connection management
void onClientConnect(cUOSocket* socket) {
QString ip = socket->getAddress();
Log::instance()->print(QString("Client connected from %1\n").arg(ip));
// Set socket state
socket->setState(STATE_LOGIN);
}
// Disconnect handling
void onClientDisconnect(cUOSocket* socket) {
if (socket->player()) {
socket->player()->setSocket(nullptr);
Accounts::instance()->getAccount(socket->player())->setInUse(false);
}
}
```
--------------------------------
### Multi-Call LZMA Decompression with Output Buffer (RAM to File)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/lzma.txt
Handles LZMA decompression in multiple calls for RAM-to-File operations. Requires input buffer, an output buffer, and initialization of the decoder with LzmaDecoderInit. The loop continues as long as more bytes are needed.
```c
state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
LzmaDecoderInit(&state);
do
{
LzmaDecode(&state,
inBuffer, inAvail, &inProcessed,
g_OutBuffer, outAvail, &outProcessed);
inAvail -= inProcessed;
inBuffer += inProcessed;
}
while you need more bytes
```
--------------------------------
### Adding Benchmark Command for Speed and Error Checking
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/history.txt
Introduces a new 'Benchmark' command that measures compression and decompression speeds, displays performance ratings, and checks for hardware errors. This utility aids in evaluating system performance and stability.
```c
/* Version 4.03 */
/* "Benchmark" command was added. It measures compressing and decompressing speed and shows rating values. Also it checks hardware errors. */
```
--------------------------------
### Extract Single File from 7z Archive (C)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zC.txt
Illustrates how to extract a single file from a 7z archive using the SzExtract function. It details the necessary parameters for the function, including input stream, archive database, file index, and memory allocators. The output buffer and processed size are returned.
```c
SZ_RESULT SzExtract(
ISzInStream *inStream,
CArchiveDatabaseEx *db,
UInt32 fileIndex, /* index of file */
UInt32 *blockIndex, /* index of solid block */
Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */
size_t *outBufferSize, /* buffer size for output buffer */
size_t *offset, /* offset of stream for required file in *outBuffer */
size_t *outSizeProcessed, /* size of file in *outBuffer */
ISzAlloc *allocMain,
ISzAlloc *allocTemp);
/* If you need to decompress more than one file, you can send these values from previous call:
blockIndex,
outBuffer,
outBufferSize,
You can consider "outBuffer" as cache of solid block. If your archive is solid, */
```
--------------------------------
### NID kSubStreamsInfo Structure (C++)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zFormat.txt
Contains information about substreams, including the number of unpack streams per folder. This is essential for reconstructing complex data streams.
```C++
BYTE NID::kSubStreamsInfo; (0x08)
BYTE NID::kNumUnPackStream; (0x0D)
UINT64 NumUnPackStreamsInFolders[NumFolders];
```
--------------------------------
### NID kCodersUnPackSize Structure (C++)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zFormat.txt
Specifies the unpack size for coders associated with each folder and its outgoing streams. This is crucial for decompressing data.
```C++
BYTE ID::kCodersUnPackSize (0x0C)
for(Folders)
for(Folder.NumOutStreams)
UINT64 UnPackSize;
```
--------------------------------
### Index File Data Structure and Lookup
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/formats/index.html
Describes the structure of index files used for looking up data in other MUL files. It specifies the fields 'lookup', 'length', and 'extra', and explains the process of seeking and reading data based on an 'EntryID'.
```c
struct IndexEntry {
int lookup;
int length;
int extra;
};
```
```pseudocode
function read_data(entry_id, index_file, data_file) {
seek(index_file, entry_id * 12);
index_entry = read(index_file, sizeof(IndexEntry));
seek(data_file, index_entry.lookup);
data = read(data_file, index_entry.length);
return data;
}
```
--------------------------------
### Python Client-Side Dialog System Scripting
Source: https://context7.com/mbnunes/wolfpack-qt5/llms.txt
Enables client-side UI dialogs scripted in Python. Supports dynamic creation of sub-dialogs, adding controls, and handling UI events like button clicks. It interacts with a `client` module for game-specific functionalities like network requests and GUI operations. Dialogs are typically defined using an XML format.
```python
# Client-side dialog initialization
from client import *
def initialize(dialog):
"""Initialize dialog with sub-dialogs and controls"""
container = dialog.findByName("CharacterCreationContainer")
# Create and add sub-dialogs dynamically
charcreation1 = Gui.createDialog("CharacterCreation1")
if charcreation1:
container.addControl(charcreation1)
charcreation2 = Gui.createDialog("CharacterCreation2")
if charcreation2:
container.addControl(charcreation2)
charcreation3 = Gui.createDialog("CharacterCreation3")
if charcreation3:
container.addControl(charcreation3)
# Dialog event handling
def onButtonClick(dialog, button):
"""Handle button click events"""
buttonName = button.getName()
if buttonName == "LoginButton":
username = dialog.findByName("UsernameField").getText()
password = dialog.findByName("PasswordField").getText()
Network.sendLoginRequest(username, password)
elif buttonName == "CancelButton":
dialog.close()
# XML dialog definition example
"""
"""
```
--------------------------------
### 7z Archive Properties Structure
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zFormat.txt
Illustrates the structure for defining archive-level properties within a 7z file. This section handles metadata and configuration specific to the archive.
```C++
BYTE NID::kArchiveProperties (0x02)
while(true)
{
BYTE PropertyType;
if (aType == 0)
break;
UINT64 PropertySize;
BYTE PropertyData[PropertySize];
}
```
--------------------------------
### NID kHeader Structure (C++)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/client/7zip/7zFormat.txt
Represents the main archive header, containing archive properties, additional stream information, main stream information, and file information.
```C++
BYTE NID::kHeader (0x01)
ArchiveProperties;
BYTE NID::kAdditionalStreamsInfo; (0x03)
StreamsInfo;
BYTE NID::kMainStreamsInfo; (0x04)
StreamsInfo;
FilesInfo;
```
--------------------------------
### Krrios Sound Data Structure (C)
Source: https://github.com/mbnunes/wolfpack-qt5/blob/master/server/docs/webroot/formats/sounds.html
Defines the structure of the data within the Sound.mul file, including the filename, an unknown header, and the raw wave data. The wave data can be extracted to form a .wav file.
```c
char filename[20]; // Original *.wav file name
byte header[20]; // Unknown
byte waveData[length - 40]; // Raw wave audio data
```