forked from kelno/import_scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgob_import.php
More file actions
51 lines (41 loc) · 1.48 KB
/
gob_import.php
File metadata and controls
51 lines (41 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
include_once(__DIR__ . '/lib/helpers.php');
include_once(__DIR__ . '/lib/common.php');
include_once(__DIR__ . '/config.php');
$output_filename = "gameobject.sql";
$file = fopen($output_filename, "w");
if (!$file)
die("Couldn't open {$output_filename}");
$start = microtime(true);
$debug = false;
$converter = new DBConverter($file, $debug);
$conn = new PDO("mysql:host=localhost", $login, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = "SELECT tc.*
FROM $tcWorld.gameobject tc
WHERE tc.import IS NOT NULL AND tc.import != 'IGNORE'";
// MAIN
$stmt = $conn->query($query);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
foreach($stmt->fetchAll() as $v) {
fwrite($file, "-- Importing gameobject spawn with guid {$v['guid']} with import type {$v['import']}" . PHP_EOL);
$guid = $v['guid'];
$gob_id = $v["id"];
switch($v["import"])
{
case "IMPORT": //Straight import the gameobject, no delete of anything.
$converter->ImportTCGameObject($guid);
break;
case "REPLACE_ALL": //Remove all gameobjects with this id from sun, and replace with all gameobjects from TC with this id
$converter->CreateReplaceAllGameObject($gob_id);
break;
default:
echo "ERROR: Non handled enum value: " . $v["import"] . PHP_EOL;
exit(1);
}
fwrite($file, PHP_EOL . PHP_EOL);
}
fclose($file);
$duration = microtime(true) - $start;
$duration = number_format($duration, 4);
echo PHP_EOL . "Finished in {$duration}s with {$warnings} warnings and {$errors} errors" . PHP_EOL;