Command hulking war machines in tense, turn-based duels where every choice matters. Manage heat, target specific limbs, and fine-tune your loadout to outthink and outmaneuver rival pilots. With body-part damage, ammo discipline, and precise timing, Metal Mech rewards tactical minds who love the rhythm of careful positioning and decisive strikes.
Tune your mech, climb the ladder, and master the art of resource management under pressure. This rare browser mech sim captures the thrill of heavyweight combat with accessible systems and satisfying depth—perfect for players who crave strategy over button-mashing.
Title: MetalMech v0.2.6
Genre: Mech Combat Simulation / Browser-Based RPG
Release Date: ~2005-2006 (beta stage)
Developer: Dzmitry A. Haiduchonak
Distribution: SourceForge project (http://sourceforge.net/projects/metalmech/)
License: GNU General Public License v2 (June 1991)
Project Status: Beta/Early Development (v0.2.6)
Archive Structure:
metal_mech_v0.2.6/
└── MetalMech v0.2.6/
├── battle/ # Combat system (1,581-line monolith)
├── configs/ # Configuration files
├── cron/ # Scheduled tasks
├── event/ # Event handlers
├── includes/ # Core functions (2,157-line functions.inc)
├── pilot/ # Player management (562 lines)
├── plant/ # Base/factory management
├── Smarty/ # Template engine (v2.6.9+)
├── templates/ # Smarty templates (33 TPL files)
├── templates_c/ # Compiled templates
├── xml/ # XML schema definitions
├── xml_data/ # Player data storage (XML-based)
├── xml_dtd/ # DTD definitions
├── install.php # Web-based installation wizard
└── COPYING, INSTALL # Documentation
<code></code>`
Historical Context:
MetalMech represents a significant departure from the mafia/crime game dominance of mid-2000s browser RPGs. While MCCodes (game 39) defined the mafia genre standard in 2008-2015, MetalMech pioneered mech combat simulation in browser format circa 2005. This was the era of BattleTech tabletop gaming's peak popularity, and MetalMech attempted to translate turn-based mech combat to web browsers using cutting-edge (for 2005) XML data persistence and template-driven architecture.
First in Collection:
---
FLOW: Browser → index.php → /pilot/ or /battle/ → Smarty Templates → XML Files
↓
functions.inc (2,157 lines)
open_xml() / save_xml()
↓
xml_data/pilot/*.xml
xml_data/battle/*.xml
<code></code>`
Unique Architectural Decisions:
System Requirements (from INSTALL):
PHP >= 5.0.3
Smarty >= 2.6.9
DOM extension enabled
XSLT extension enabled
<code></code>`
Code Statistics:
---
1. Pilot System (pilot/index.php - 562 lines)
2. Mech Management
XML structure (xml/mech_default.xml):
<mech name="ZX-22">
<status val="live"/>
<pilot name="You" pid=""/>
<params>
<lvl val="0"/>
<heat val="0"/> <!-- Heat management crucial -->
<maxheat val="20"/>
<speed val="10"/>
<heatdown val="1"/> <!-- Heat dissipation -->
</params>
<body>
<lh><hp val="20"/></lh> <!-- Left Hand -->
<rh><hp val="20"/></rh> <!-- Right Hand -->
<ll><hp val="20"/></ll> <!-- Left Leg -->
<rl><hp val="20"/></rl> <!-- Right Leg -->
<h><hp val="10"/></h> <!-- Head -->
<f><hp val="40"/></f> <!-- Front armor -->
<r><hp val="30"/></r> <!-- Rear armor -->
</body>
</mech>
<code></code>`
3. Battle System (battle/index.php - 1,581 lines)
From developer comments:
// know bugs:
// + 1. do not increment turns >2, if PHPSESSION same for both enemies
// 2. not dead on heat overrev
// 3. heat not calculated if no hit
// 4. need XML file locks
// 5. error storing damage result in b.xml (duplicating turn number)
// to do:
// +1. finish calculating results of rocket fire
// +2. write calculating results of pulse gun fire
// +3. write calculating overall params (+damage, +weight, +loadweight, +heat, +ammo usage)
// +4. write in battle turn result information (+hits, +damages, other)
// +5. advanced mech info (+damage, +weapons, status)
// +6. implement many independent battlefields
// +7. end of turn after 120 sec wait, implement time info in b.xml/turns
// 8. external event handler
// +9. choose enemy form
// 10. mech management forms
// 11. in battle chat
<code></code>`
Battle Flow:
// Algorithm of battle:
// 1. get two mechs and put it into battle.xml (over xslt)
// 1.1 init pilot params
// 1.2 if all ok - begin battle
// 2. get mech info and write battlefield
// 3. put mech action into b.xml
// 4. get results of actions
// 5. check status of battle, end of turn
// 5.1. go to 2
// 5.2. if battle ends - exit
<code></code>`
Turn Mechanics:
Weapon Systems (from XML):
<weapon wid="1">
<lvl val="0"/>
<hp val="10"/>
<name val="SAM 2xA"/>
<wtype val="rocket"/> <!-- Weapon types: rocket, pulse gun -->
<weight val="1"/>
<heating val="+1"/> <!-- Heat generation per shot -->
<load lid="1">
<name val="SAM 2xA 10 rocket pack"/>
<!-- Ammunition tracking -->
</load>
</weapon>
<code></code>`
4. Plant System (plant/index.php)
5. Event/Cron Systems
---
CRITICAL ISSUES:
1. Unescaped GET/POST Parameters (20+ instances)
// battle/index.php:150
$action=$_GET["action"]; // NO ESCAPING!
// amountbar.php:109-114
$rating=$_GET["rating"]; // Direct usage
$max=$_GET["max"];
<code></code>`
2. Insufficient Input Validation (install.php)
// install.php:116
if ( file_exists($_POST['PATH']) && file_exists($_POST['DATA']) ... ) {
// Directly writes user input to config file!
define("PATH", "'.$_POST['PATH'].'");
<code></code>`
3. XML External Entity (XXE) Attacks
// functions.inc:40
$xml = new DOMDocument();
$ret = @$xml->loadXML($xml_text); // @ suppresses errors, no XXE prevention
<code></code>`
4. Error Suppression
@$xml->loadXML($xml_text); // Hides security-critical errors
@chmod($_POST['XMLDATA'],0777); // Dangerous permission changes hidden
@chown($_POST['XMLDATA'],$_ENV['USER']);
<code></code>`
POSITIVE SECURITY FEATURES:
1. File Locking Discipline
// functions.inc:16-29
for($handler = fopen($path_to_file,"r");$handler === false;){
if (FALSE != DEBUG) {
$x++;
if ($x>10) {
print "Error unlocking ".$path_to_file;
die();
}
}
sleep(1);
}
if (flock($handler, LOCK_EX)) {
// Exclusive lock prevents race conditions
}
<code></code>`
2. Smarty Template Security
// Smarty/plugins/modifier.escape.php:25
return htmlspecialchars($string, ENT_QUOTES); // XSS protection built-in
<code></code>`
3. Session-Based Authentication
session_start();
$sid=session_id();
define("SID", $sid); // Session tracking per pilot
<code></code>`
4. GPL v2 License = Auditable Code
CRITICAL VULNERABILITIES BY IMPACT:
| Vulnerability | Severity | Location | Impact |
|---|---|---|---|
| Unescaped GET/POST | HIGH | battle/index.php:150, amountbar.php:109-114 | XSS, SQL injection (if DB added) |
| Path traversal | HIGH | install.php:116-148 | Arbitrary file write |
| XXE attacks | MEDIUM | functions.inc:40 | Server-side request forgery |
| Error suppression | MEDIUM | Multiple files | Hidden vulnerabilities |
| 0777 permissions | LOW | install.php:166 | File system exposure |
RECOMMENDATION:
Needs major security hardening before production use. Beta status excuses some issues, but GET/POST escaping should be mandatory from day one. File locking is excellent, but input validation is dangerously absent.
---
STRENGTHS:
1. Professional Template Separation
// pilot/index.php:36-46
require '../Smarty/Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = true; // Development mode
<code></code>`
2. Comprehensive Documentation
// Battle system has 50+ lines of developer comments
// Detailed TODO lists and known bugs documented
// Algorithm pseudocode in comments
<code></code>`
3. Modular Directory Structure
battle/ - Combat system (isolated)
pilot/ - Player management (isolated)
plant/ - Factory system (isolated)
includes/ - Shared functions (DRY principle)
<code></code>`
4. Advanced File Locking
// functions.inc implements retry logic with exponential backoff
// Global $fp array tracks open file handlers
// Proper cleanup in save_xml()
<code></code>`
WEAKNESSES:
1. Monolithic Battle Controller
2. Giant Helper Function Library
3. Beta-Quality Error Handling
if (!$ret) {
echo "Error while parsing the document n".$path_to_file;
print $xml_text; // Dumps raw XML to screen!
fclose($handler);
exit;
}
<code></code>`
4. Incomplete Features
From TODO comments:
5. Frame-Based UI (2005 Anti-Pattern)
$refreshcode = "window.setTimeout("top.frames.location.href='".$site."index.php?refresh=1'",".(TIMEOUT*250).")";
<code></code>`
ARCHITECTURE COMPARISON:
| Feature | MetalMech | MCCodes v2.0 | Verdict |
|---|---|---|---|
| Template Engine | Smarty 2.6.9 | None (inline HTML) | MetalMech superior |
| Data Storage | XML files | MySQL database | ⚖️ Depends on scale |
| MVC Pattern | Yes (Smarty) | No (spaghetti) | MetalMech superior |
| Code Organization | Modular dirs | Flat structure | MetalMech superior |
| File Size | 1,581-line monolith | 1,417-line monolith | ⚖️ Both have monoliths |
| Community Support | SourceForge (dead?) | Massive ecosystem | MCCodes wins |
| Production Ready | Beta quality | Released product | MCCodes wins |
---
Pilot Profile (xml/pilot_default.xml - 199 lines):
<pilot name="" login="">
<login status="" date="">
<sid val=""/> <!-- Session ID -->
<ip val=""/> <!-- IP tracking -->
<cw val=""/> <!-- Unknown token -->
</login>
<status>
<battle status="free" date=""/> <!-- free|fighting -->
</status>
<info>
<password val=""/> <!-- WARNING: Plaintext? -->
<name first="" last=""/>
<country val=""/>
<city val=""/>
<email val=""/>
<icq val=""/> <!-- 2005 nostalgia! -->
</info>
<params>
<lvl val="0"/>
<hp val="100"/>
<exp val="0" type="battle"/> <!-- Dual experience types -->
<exp val="0" type="trade"/> <!-- Trading system planned -->
</params>
<world>
<mechs>
<mech mid="1" name="ZX-22">...</mech>
</mechs>
</world>
</pilot>
<code></code>`
Mech Configuration (7 body parts with individual HP):
<body>
<lh><hp val="20" max="20"/><weight val="5"/></lh> <!-- Left Hand -->
<rh><hp val="20" max="20"/><weight val="5"/></rh> <!-- Right Hand -->
<ll><hp val="20" max="20"/><weight val="10"/></ll> <!-- Left Leg -->
<rl><hp val="20" max="20"/><weight val="10"/></rl> <!-- Right Leg -->
<h><hp val="10" max="10"/><weight val="2"/></h> <!-- Head -->
<f><hp val="40" max="40"/><weight val="15"/></f> <!-- Front -->
<r><hp val="30" max="30"/><weight val="10"/></r> <!-- Rear -->
</body>
<code></code>`
Heat Management System:
<params>
<heat val="0"/> <!-- Current heat -->
<maxheat val="20"/> <!-- Shutdown threshold -->
<heatdown val="1"/> <!-- Heat dissipation per turn -->
</params>
<code></code>`
Weapon Loadouts:
<weapon wid="1">
<lvl val="0"/>
<hp val="10"/> <!-- Weapon can be damaged -->
<name val="SAM 2xA"/>
<wtype val="rocket"/>
<weight val="1"/>
<heating val="+1"/> <!-- +1 heat per shot -->
<load lid="1">
<name val="SAM 2xA 10 rocket pack"/>
<!-- Ammo tracking -->
</load>
</weapon>
<code></code>`
XML File Operations (functions.inc:11-107):
open_xml($path, $readonly=false)
├─> Loop: fopen() until success (10 retries)
├─> flock(LOCK_EX) for exclusive access
├─> Read entire file (8192-byte chunks)
├─> DOMDocument->loadXML()
├─> Store $handler in global $fp array
└─> Return DOMDocument
save_xml($path, $xml, $is_new=false)
├─> $xml->saveXML() to string
├─> Find $handler in global $fp array
├─> fclose() previous handler
├─> fopen($path, "w") with retries
├─> fwrite() XML content
├─> fclose()
└─> Return status
<code></code>`
Turn-Based Combat Flow:
a. Weapon damage to body parts
b. Heat accumulation
c. Check heat > maxheat (shutdown?)
d. Check HP <= 0 (death?)
Battle State Machine:
free → waiting → fighting → results
↑ ↓
└────────────────────────────┘
<code></code>`
Data Persistence Strategy:
NO DATABASE!
xml_data/pilot/arch/{login}.xml - Player profiles
xml_data/battle/{bid}.xml - Active battles
xml/pilot_default.xml - New player template
xml/mech_default.xml - New mech template
<code></code>`
---
MetalMech's Position:
Contemporary Landscape (2005-2006):
1. Beta Hell:
// TODO comments reveal 50% of features incomplete
// Known bugs in core combat system
// No public v1.0 release found
<code></code>`
2. XML Scalability Problems:
3. Frame-Based UI Already Obsolete:
4. Niche Within Niche:
5. PHP 5.0 Required:
// INSTALL: need PHP >=5.0.3
<code></code>`
vs MCCodes v2.0 (2008):
| Aspect | MetalMech (2005) | MCCodes (2008) |
|---|---|---|
| Architecture | Modern (Smarty MVC) | Primitive (inline HTML) |
| Data Storage | XML files | MySQL database |
| Community | Dead on arrival | Massive ecosystem |
| Genre | Mech combat (niche) | Mafia (mainstream) |
| Completion | Beta (50%) | Full release |
| Historical Impact | None | Defined genre for decade |
vs Ravan Scripts (game 37, commercial):
| Aspect | MetalMech (GPL v2) | Ravan Scripts |
|---|---|---|
| License | Free/open source | Commercial ($$$) |
| Support | SourceForge forums | Vendor support |
| Updates | Abandoned 2006? | Active until ~2012 |
| Security | Open to audit | Security through obscurity |
| Customization | Full source access | Encrypted files |
MetalMech represents a category of browser games that technically succeeded but commercially failed:
Technical Achievement:
Market Failure:
Lesson: Technical excellence ≠ commercial success. MCCodes' primitive spaghetti code created a 7-year industry standard, while MetalMech's superior architecture vanished into obscurity.
---
Required:
// Smarty Template Engine
require '../Smarty/Smarty.class.php'; // v2.6.9+, GPL v2.1
<code></code>`
Optional (Development):
// PEAR Benchmark_Timer
require_once 'Benchmark/Timer.php'; // Performance profiling
<code></code>`
From install.php verification:
version_compare(phpversion(), "5.0.4", ">="); // PHP 5.0.4+
// DOM extension (for DOMDocument)
// XSLT extension (commented out but planned)
<code></code>`
Permissions:
// install.php:118-132
if (fileperms($_POST['PATH']) < 16832) { // 0755 octal
echo "Permission denied";
}
@chmod($_POST['XMLDATA'],0777); // World-writable XML data!
<code></code>`
Directory Structure:
CONFIGURED after installation:
define("PATH", "/path/to/metalmech/");
define("DATA", "/path/to/data/");
define("XMLDATA", "/path/to/xml_data/");
define("GLOBALSITE", "http://example.com");
<code></code>`
Pros:
Cons:
Smarty Template Engine (bundled):
PEAR Benchmark_Timer (optional):
// pilot/index.php:29-33
if (FALSE != DEBUG) {
require_once 'Benchmark/Timer.php'; // Performance profiling
$timer = new Benchmark_Timer();
}
<code></code>`
Traditional LAMP Stack:
Linux/Windows
├─> Apache/nginx (PHP module)
│ ├─> PHP 5.0.3+ (DOM extension)
│ └─> Smarty 2.6.9+ (bundled)
└─> File System (XML storage)
└─> xml_data/ (0777 permissions)
<code></code>`
Modern Deployment (Hypothetical):
---
What's Present:
What's Missing:
Playability Status:
Can Install: YES (install.php wizard functional)
Can Register: YES (pilot/index.php has registration)
Can Login: YES (session-based authentication)
Can Battle: PARTIAL (core combat works, but bugs noted)
Can Customize Mech: NO (management UI incomplete)
Can Trade: NO (system not implemented)
<code></code>`
Historical Significance:
Cautionary Tale:
To Run Today (PHP 8.x):
// Minor compatibility fixes needed:
To Modernize (2024 standards):
Estimated Effort:
In This Collection (Games 1-40):
In Wild:
---
RATING BREAKDOWN:
| Category | Score | Reasoning |
|---|---|---|
| Security | 5/10 | File locking excellent, input validation absent |
| Code Quality | 6/10 | MVC architecture vs 1,581-line monolith |
| Completeness | 7/10 | Core loop works, 50% features missing |
| Innovation | 8/10 | Smarty+XML in 2005 = ahead of time |
| Playability | 5/10 | Beta bugs, incomplete features, frame-based UI |
| Historical Impact | 3/10 | Zero community adoption, abandoned |
| Preservation Value | 7/10 | Complete source, rare genre, technical lessons |
STRENGTHS:
WEAKNESSES:
Comparison to Collection Standards:
Justification:
Educational Value:
Restoration Projects:
Code Archaeology:
MetalMech v0.2.6 represents what could have been:
The Lesson: In browser gaming's wild west era, market timing and genre choice mattered more than technical excellence. MCCodes' mafia theme and complete (if sloppy) execution beat MetalMech's sophisticated but incomplete mech combat simulation.
Technical Quality: 🏆 Superior to MCCodes (Smarty MVC, clean structure, file locking)
Market Success: 💀 Total Failure (never escaped beta, zero adoption)
Historical Value: 📚 High (architectural innovation, genre diversity, cautionary tale)
Playability: ⚠️ Beta Quality (core works, features incomplete, known bugs)
Recommendation: PRESERVE as example of "technical excellence doesn't guarantee success" in browser gaming history. MetalMech's GPL v2 source code is a valuable lesson in 2005-era PHP architecture, NoSQL experimentation, and the perils of beta development hell.
---
Archive Status: PRESERVED
Analysis Date: 2024
Game Number: 40 of 79
Analyst Notes: First non-mafia game encountered, first true GPL v2 license, first Smarty templating engine, first database-free design. Technical quality exceeds many commercial alternatives from same era, but beta status and niche genre prevented any market adoption. Source code is complete enough for educational study but incomplete for production deployment. Represents important counterpoint to MCCodes' commercial success—sometimes the "worse" product wins.
| Category | Rating | Commentary |
|---|---|---|
| Innovation & Originality | ★★★★★★★★★☆ 9/10 | First non-mafia game, mech combat genre, XML persistence, Smarty templates |
| Code Quality | ★★★★★★★☆☆☆ 7/10 | Professional MVC, Smarty templates, but large monolithic files (1,581 lines) |
| Security Posture | ★★★★★★☆☆☆☆ 6/10 | File locking implemented, but XML-based auth, needs input validation review |
| Documentation | ★★★★★★☆☆☆☆ 6/10 | INSTALL, COPYING files, inline comments, GPL v2 license |
| Gameplay Design | ★★★★★★★★☆☆ 8/10 | Complete mech combat: pilot management, mech customization, turn-based battles |
| Technical Architecture | ★★★★★★★★☆☆ 8/10 | Smarty MVC, XML data layer, modular controllers, file locking discipline |
| Completeness | ★★★★★☆☆☆☆☆ 5/10 | Beta v0.2.6, functional but incomplete, active development (SourceForge) |
| Historical Significance | ★★★★★★★★☆☆ 8/10 | First mech combat browser game, BattleTech homage, 2005 innovation |
| Preservation Value | ★★★★★★★★☆☆ 8/10 | Important genre diversification, XML persistence example, GPL licensed |
Summary: MetalMech v0.2.6 (2005) is a groundbreaking mech combat browser game that broke the mafia game monopoly with BattleTech-inspired turn-based strategy. Using pure XML data persistence (no database!), Smarty template engine for true MVC separation, and professional file locking discipline, it demonstrates advanced architecture for its era. With GPL v2 license and SourceForge distribution, it represents proper open-source development. Though incomplete (beta v0.2.6), it features complete pilot management, mech customization, and combat systems across 3,897 lines of organized code. First of its kind - proving browser games could transcend crime/mafia themes. Excellent preservation value for studying XML-based game engines and genre innovation.
Running many of the scripts in this archive on a live server presents a serious security risk. These projects were created before modern hardening practices and may contain vulnerabilities that can compromise your system.
We strongly recommend using this code for reference and analysis only, or in isolated local environments. By downloading these files, you accept full responsibility for their use.