forked from aburch/simutrans
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsimware.cc
111 lines (86 loc) · 1.72 KB
/
simware.cc
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* simware.cc
*
* Copyright (c) 1997 - 2001 Hansjörg Malthaner
*
* This file is part of the Simutrans project and may not be used
* in other projects without written permission of the author.
*/
#include <stdio.h>
#include <string.h>
#include "simio.h"
#include "simmem.h"
#include "simdebug.h"
#include "simtypes.h"
#include "simware.h"
#include "dataobj/translator.h"
#include "dataobj/loadsave.h"
#include "dataobj/koord.h"
#include "utils/cstring_t.h"
#include "besch/ware_besch.h"
#include "bauer/warenbauer.h"
#ifdef _MSC_VER
#define STRICMP stricmp
#else
#define STRICMP strcasecmp
#endif
/**
* gibt den nicht-uebersetzten warennamen zurück
* @author Hj. Malthaner
*/
const char *ware_t::gib_name() const
{
return type->gib_name();
}
int ware_t::gib_preis() const
{
return type->gib_preis();
}
int ware_t::gib_catg() const
{
return type->gib_catg();
}
const char *ware_t::gib_mass() const
{
return type->gib_mass();
}
ware_t::ware_t() : ziel(-1, -1), zwischenziel(-1, -1), zielpos(-1, -1)
{
menge = 0;
max = 0;
type = 0;
}
ware_t::ware_t(const ware_besch_t *wtyp) : ziel(-1, -1), zwischenziel(-1, -1), zielpos(-1, -1)
{
menge = 0;
max = 0;
type = wtyp;
}
ware_t::ware_t(loadsave_t *file)
{
rdwr(file);
}
ware_t::~ware_t()
{
menge = 0;
max = 0;
type = 0;
}
void
ware_t::rdwr(loadsave_t *file)
{
file->rdwr_int(menge, " ");
file->rdwr_int(max, " ");
const char *typ = NULL;
if(file->is_saving()) {
typ = type->gib_name();
}
file->rdwr_str(typ, " ");
if(file->is_loading()) {
type = warenbauer_t::gib_info(typ);
guarded_free(const_cast<char *>(typ));
}
ziel.rdwr(file);
zwischenziel.rdwr(file);
zielpos.rdwr(file);
}