1 | <?php
|
---|
2 |
|
---|
3 | include_once(dirname(__FILE__).'/../../Base/Model.php');
|
---|
4 |
|
---|
5 | class Emulator extends Model
|
---|
6 | {
|
---|
7 | var $Id;
|
---|
8 | var $Emulator;
|
---|
9 | var $Task;
|
---|
10 |
|
---|
11 | function __construct($System, $Id)
|
---|
12 | {
|
---|
13 | parent::__construct($System);
|
---|
14 | $this->Task = new Task($System);
|
---|
15 | $this->Id = $Id;
|
---|
16 | $DbResult = $this->Database->query('SELECT * FROM `Emulator` WHERE `Id`='.$Id);
|
---|
17 | $this->Emulator = $DbResult->fetch_assoc();
|
---|
18 | $DbResult = $this->Database->query('SELECT * FROM `Client` WHERE `Id`='.$this->Emulator['Client']);
|
---|
19 | $this->Emulator['Client'] = $DbResult->fetch_assoc();
|
---|
20 | }
|
---|
21 |
|
---|
22 | function Add()
|
---|
23 | {
|
---|
24 | $EmulatorDir = '../emulator/'.$this->Id.'/';
|
---|
25 | if(!file_exists($EmulatorDir)) mkdir($EmulatorDir, 0777, true);
|
---|
26 |
|
---|
27 | //$this->AddTask('Vytvoření nového emulátoru', array(
|
---|
28 | // 'ln -s wowclient/'.$this->Emulator['Client']['Version'].'/maps emulator/'.$this->Emulator['Id'].'/mangos/maps',
|
---|
29 | // 'ln -s wowclient/'.$this->Emulator['Client']['Version'].'/dbc emulator/'.$this->Emulator['Id'].'/mangos/dbc',
|
---|
30 | //));
|
---|
31 | $this->Download();
|
---|
32 | $this->Compile();
|
---|
33 | }
|
---|
34 |
|
---|
35 | function Download()
|
---|
36 | {
|
---|
37 | $this->Lock();
|
---|
38 | $this->Task->Add('Stažení emulátoru', array(
|
---|
39 | 'php www/shell.php EmulatorLock '.$this->Id,
|
---|
40 | 'mkdir '.$this->Config['BaseDir'].'emulator/'.$this->Id.'/',
|
---|
41 | 'cd '.$this->Config['BaseDir'].'emulator/'.$this->Id.'/',
|
---|
42 | 'git clone git://github.com/mangos/mangos.git source',
|
---|
43 | 'cd source',
|
---|
44 | 'git checkout '.$this->Emulator['CommitHash'],
|
---|
45 | 'mkdir src/bindings/ScriptDev2',
|
---|
46 | 'svn checkout -r '.$this->Emulator['ScriptDev2Revision'].' https://scriptdev2.svn.sourceforge.net/svnroot/scriptdev2/ src/bindings/ScriptDev2',
|
---|
47 | 'git apply src/bindings/ScriptDev2/patches/'.$this->Emulator['ScriptDev2PatchFileName'],
|
---|
48 | 'cd ../../..',
|
---|
49 | 'php www/shell.php EmulatorUnLock '.$this->Id,
|
---|
50 | ));
|
---|
51 | }
|
---|
52 |
|
---|
53 | function Compile()
|
---|
54 | {
|
---|
55 | $this->Lock();
|
---|
56 | $this->Task->Add('Překlad emulátoru', array(
|
---|
57 | 'php www/shell.php EmulatorLock '.$this->Id,
|
---|
58 | 'cd '.$this->Config['BaseDir'].'emulator/'.$this->Id.'/source',
|
---|
59 | 'autoreconf -ifv',
|
---|
60 | 'mkdir objdir',
|
---|
61 | 'cd objdir',
|
---|
62 | 'export CFLAGS="-g -ggdb '.$this->Config['CompilerParameters'].'"',
|
---|
63 | 'export CXXFLAGS="-g -ggdb '.$this->Config['CompilerParameters'].'"',
|
---|
64 | '../configure --prefix='.$this->Config['BaseDir'].'emulator/'.$this->Id.'/ --enable-cli --enable-ra',
|
---|
65 | 'make',
|
---|
66 | 'make install',
|
---|
67 | 'cd ../../../..',
|
---|
68 | 'php www/shell.php EmulatorUnLock '.$this->Id,
|
---|
69 | ));
|
---|
70 | }
|
---|
71 |
|
---|
72 | function ExtractMaps()
|
---|
73 | {
|
---|
74 | $this->Lock();
|
---|
75 | $this->Task->Add('Vygenerování souborů map', array(
|
---|
76 | 'php www/shell.php EmulatorLock '.$this->Id,
|
---|
77 | 'cd wowclient/'.$this->Emulator['Client']['Version'].'/client',
|
---|
78 | 'wine emulator/'.$this->Id.'/source/contrib/extractor/ad.exe',
|
---|
79 | 'mv wowclient/'.$this->Emulator['Client']['Version'].'/client/dbc wowclient/'.$this->Emulator['Client']['Version'].'/',
|
---|
80 | 'mv wowclient/'.$this->Emulator['Client']['Version'].'/client/maps wowclient/'.$this->Emulator['Client']['Version'].'/',
|
---|
81 | 'cd ../../..',
|
---|
82 | 'php www/shell.php EmulatorUnLock '.$this->Id,
|
---|
83 | ));
|
---|
84 | return('Požadavek na vygenerování map zařazen.');
|
---|
85 | }
|
---|
86 |
|
---|
87 | function Lock()
|
---|
88 | {
|
---|
89 | $this->Database->update('Emulator', 'Id='.$this->Id, array('Lock' => 1));
|
---|
90 | }
|
---|
91 |
|
---|
92 | function UnLock()
|
---|
93 | {
|
---|
94 | $this->Database->update('Emulator', 'Id='.$this->Id, array('Lock' => 0));
|
---|
95 | }
|
---|
96 | }
|
---|