Incremental Refactor Market/Message/Profile

Incremental Refactor Market/Message/Profile
This commit is contained in:
Catalin Novgorodschi
2026-05-13 12:20:10 +03:00
parent a004f5352b
commit a3cf00c0f9
8 changed files with 1856 additions and 1048 deletions
+28 -15
View File
@@ -6,6 +6,7 @@
## Project: TravianZ ##
## Filename autoloader.php ##
## Developed by: Dzoki ##
## Refactored by: Shadow ##
## License: TravianZ Project ##
## Copyright: TravianZ (c) 2010-2026. All rights reserved. ##
## URLs: http://travian.shadowss.ro ##
@@ -13,25 +14,37 @@
## ##
#################################################################################
function autoloadClass($class) {
// strip the App classname's namespace
$clazz = str_replace(['App\\', '\\'], ['', '/'], $class);
function autoloadClass($class) {
// search for class
$class_found = false;
// go max 5 levels up - we don't have folders that go deeper than that
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
if (file_exists($autoprefix.'src/' . $clazz . '.php')) {
$class_found = true;
include_once $autoprefix.'src/' . $clazz . '.php';
break;
}
$clazz = str_replace(['App\\', '\\'], ['', '/'], $class);
$class_found = false;
for ($i = 0; $i < 5; $i++) {
$autoprefix = str_repeat('../', $i);
// 1. default path (actual)
$path1 = $autoprefix . 'src/' . $clazz . '.php';
// 2. fallback GameEngine (YOUR CASE)
$path2 = $autoprefix . 'GameEngine/' . $clazz . '.php';
if (file_exists($path1)) {
include_once $path1;
$class_found = true;
break;
}
if (!$class_found) {
throw new Exception('Unable to find class ' . $clazz . '.');
if (file_exists($path2)) {
include_once $path2;
$class_found = true;
break;
}
}
if (!$class_found) {
throw new Exception('Unable to find class ' . $clazz . '.');
}
}
spl_autoload_register('autoloadClass');