Crossfire Server, Trunk
Treasures.cpp
Go to the documentation of this file.
1
/*
2
* Crossfire -- cooperative multi-player graphical RPG and adventure game
3
*
4
* Copyright (c) 2020 the Crossfire Development Team
5
*
6
* Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
7
* welcome to redistribute it under certain conditions. For details, please
8
* see COPYING and LICENSE.
9
*
10
* The authors can be reached via e-mail at <crossfire@metalforge.org>.
11
*/
12
13
#include "
Treasures.h
"
14
15
treasurelist
*
Treasures::create
(
const
std::string&
name
) {
16
treasurelist
*tl = (
treasurelist
*)calloc(1,
sizeof
(
treasurelist
));
17
tl->
name
=
add_string
(
name
.c_str());
18
return
tl;
19
}
20
21
void
Treasures::destroy
(
treasurelist
*
item
) {
22
if
(
item
->name)
23
free_string
(
item
->name);
24
if
(
item
->items)
25
treasure_free
(
item
->items);
26
free(
item
);
27
}
28
29
void
Treasures::replace
(
treasurelist
*existing,
treasurelist
*update) {
30
if
(existing->
items
) {
31
treasure_free
(existing->
items
);
32
}
33
existing->
items
= update->
items
;
34
existing->
total_chance
= update->
total_chance
;
35
update->
items
= NULL;
36
destroy
(update);
37
}
add_string
sstring add_string(const char *str)
Definition:
shstr.c:124
treasure_free
void treasure_free(treasure *t)
Definition:
treasure.c:1374
treasureliststruct::name
sstring name
Definition:
treasure.h:83
free_string
void free_string(sstring str)
Definition:
shstr.c:280
Treasures.h
treasureliststruct::total_chance
int16_t total_chance
Definition:
treasure.h:84
treasureliststruct::items
struct treasurestruct * items
Definition:
treasure.h:89
Treasures::replace
virtual void replace(treasurelist *existing, treasurelist *update)
Definition:
Treasures.cpp:29
Treasures::destroy
virtual void destroy(treasurelist *item)
Definition:
Treasures.cpp:21
item
Definition:
item.py:1
Treasures::create
virtual treasurelist * create(const std::string &name)
Definition:
Treasures.cpp:15
treasureliststruct
Definition:
treasure.h:82
give.name
name
Definition:
give.py:27
crossfire-crossfire-server
common
assets
Treasures.cpp
Generated by
1.8.17