Resources

100 Merc resources for MUD players

This guide provides technical specifications and implementation strategies for developers maintaining or launching a MUD based on the Merc 2.1 or 2.2 codebase. It focuses on resolving legacy C incompatibilities, understanding the structured area format, and managing the core Diku-derived architecture.

100 Merc resources for MUD players illustration
Placeholder illustration shown while custom artwork is being produced.

Compiling and Modernizing Legacy C Code

  1. 1

    GCC 10+ Compatibility Flags

    beginnerhigh

    Add -fcommon to your CFLAGS in the Makefile to resolve multiple definition errors caused by global variables in merc.h.

  2. 2

    Crypt Library Linking

    beginnerstandard

    Modern Linux distributions require linking against libcrypt explicitly; ensure -lcrypt is appended to the L_FLAGS line in your Makefile.

  3. 3

    Replacing bzero and bcopy

    intermediatestandard

    Replace deprecated bzero() calls with memset() and bcopy() with memmove() to comply with POSIX standards and avoid compiler warnings.

  4. 4

    Signal Handler Signatures

    intermediatemedium

    Update signal handler functions in comm.c to match the expected 'void function(int)' signature to prevent segmentation faults during signal traps.

  5. 5

    Implementing snprintf

    advancedhigh

    Audit sprintf calls in act_wiz.c and comm.c, replacing them with snprintf to prevent buffer overflows, a common vulnerability in Merc derivatives.

  6. 6

    Time_t Compatibility

    intermediatestandard

    Ensure all time-related variables use the time_t type rather than int to avoid 32-bit integer overflow issues on modern 64-bit systems.

  7. 7

    Malloc to Calloc Transition

    intermediatemedium

    Update memory allocation in db.c to use calloc() for automatic zero-initialization of structs, reducing 'garbage data' bugs in new mobile instances.

  8. 8

    Fixing GetHostByName

    advancedmedium

    Replace the blocking gethostbyname() in comm.c with getaddrinfo() to support IPv6 and improve DNS resolution reliability.

  9. 9

    Inline Function Modernization

    beginnerstandard

    Remove the 'inline' keyword from function definitions in handler.c if using older C standards that treat it as a linkage error.

  10. 10

    Standardizing Void Pointers

    intermediatestandard

    Cast return values of alloc_perm and alloc_mem to the specific struct pointer type to satisfy stricter type checking in modern GCC versions.

Merc Area File Format and Data Management

  1. 1

    VNUM Allocation Strategy

    beginnerhigh

    Maintain a master spreadsheet of Virtual Number (VNUM) ranges to prevent collisions between original Merc areas and custom additions.

  2. 2

    The #$ EOF Marker

    beginnerstandard

    Ensure every .are file ends with the specific '#$' string; failure to include this will cause the boot_db() function to hang or crash.

  3. 3

    Mobile Special Function Mapping

    intermediatehigh

    Assign spec_fun pointers in special.c to mobile VNUMs to enable unique behaviors like breath weapons or spellcasting.

  4. 4

    Reset Command Syntax

    intermediatestandard

    Master the 'M P G E' reset codes: M (Mobile), P (Put in container), G (Give to mob), E (Equip on mob) for population logic.

  5. 5

    Room Light Levels

    beginnermedium

    Set sector types correctly in the #ROOMS section; SECT_INSIDE and SECT_CITY affect movement point cost and light requirements.

  6. 6

    Extra Descriptions

    beginnermedium

    Utilize the 'E' flag in objects and rooms to provide 'look' targets for items that are not separate objects, saving VNUM space.

  7. 7

    Door and Exit Flags

    intermediatestandard

    Configure exit states: 0 (Open), 1 (Is Door), 2 (Pickproof Door) to control player navigation and thief skill utility.

  8. 8

    Shopkeeper Profit Margins

    beginnermedium

    Adjust the two integer values in the #SHOPS section to set the buy/sell markup; standard Merc values are 120 (buy) and 90 (sell).

  9. 9

    Area.lst Management

    beginnerhigh

    Always register new .are files in the area.lst file in the /area directory; the engine will not load files not explicitly listed here.

  10. 10

    Converting Merc to ROM

    advancedmedium

    Use automated Perl scripts to add the 'Resist' and 'Affect' bitvectors required if porting legacy Merc areas to the ROM 2.4 codebase.

Core Architecture and Systems Debugging

  1. 1

    Linked List Traversal

    intermediatehigh

    Understand the 'char_next = ch->next; ... ch = char_next;' pattern in update.c to safely extract or kill mobs during loop iterations.

  2. 2

    The Descriptor Loop

    advancedmedium

    Analyze the main game loop in comm.c to understand how non-blocking I/O handles multiple concurrent telnet connections.

  3. 3

    Experience Point Scaling

    intermediatehigh

    Modify the formula in gain_exp() within fight.c to adjust the leveling speed and prevent power-leveling via high-VNUM mob kills.

  4. 4

    Object Weight and Bulk

    intermediatestandard

    Check the apply_ac() and can_carry_w() functions to debug issues where players become encumbered or lose AC benefits.

  5. 5

    GDB Core Dump Analysis

    advancedhigh

    Use 'gdb src/merc area/core' to identify the specific line in handler.c or fight.c that caused a crash during combat.

  6. 6

    Wait State Implementation

    beginnermedium

    Control combat pacing by adjusting the WAIT_STATE macro values for skills like bash, kick, or spellcasting.

  7. 7

    Saving Player Files

    intermediatehigh

    Examine save.c to understand the keyword-based PFILE format; ensure the 'End' tag is written correctly to prevent character corruption.

  8. 8

    Adding New Skills

    intermediatehigh

    Register new skill names in the skill_table within const.c and define the corresponding spell_ or do_ function in magic.c or interp.c.

  9. 9

    Interp.c Command Priority

    beginnerstandard

    Order the command table alphabetically or by power level to ensure 'north' is parsed before custom commands starting with 'n'.

  10. 10

    Memory Recycling

    advancedmedium

    Implement a basic recycle.c system to reuse freed memory chunks, reducing the overall memory footprint of long-running Merc instances.