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
template
<>
16
treasurelist
*
asset_create
(
const
std::string&
name
) {
17
treasurelist
*tl = (
treasurelist
*)calloc(1,
sizeof
(
treasurelist
));
18
tl->
name
=
add_string
(
name
.c_str());
19
return
tl;
20
}
21
22
template
<>
23
void
asset_destroy
(
treasurelist
*
item
) {
24
if
(
item
->name)
25
free_string
(
item
->name);
26
if
(
item
->items)
27
treasure_free
(
item
->items);
28
free(
item
);
29
}
30
31
void
Treasures::replace
(
treasurelist
*existing,
treasurelist
*update) {
32
if
(existing->
items
) {
33
treasure_free
(existing->
items
);
34
}
35
existing->
items
= update->
items
;
36
existing->
total_chance
= update->
total_chance
;
37
update->
items
= NULL;
38
asset_destroy
(update);
39
}
treasurelist::items
treasure * items
Definition:
treasure.h:92
treasurelist::total_chance
int16_t total_chance
Definition:
treasure.h:87
asset_create
treasurelist * asset_create(const std::string &name)
Definition:
Treasures.cpp:16
treasurelist
Definition:
treasure.h:85
add_string
sstring add_string(const char *str)
Definition:
shstr.cpp:124
treasurelist::name
sstring name
Definition:
treasure.h:86
treasure_free
void treasure_free(treasure *t)
Definition:
treasure.cpp:1407
Treasures.h
free_string
void free_string(sstring str)
Definition:
shstr.cpp:280
asset_destroy
void asset_destroy(treasurelist *item)
Definition:
Treasures.cpp:23
item
Definition:
item.py:1
Treasures::replace
virtual void replace(treasurelist *existing, treasurelist *update) override
Definition:
Treasures.cpp:31
give.name
name
Definition:
give.py:27
crossfire-crossfire-server
common
assets
Treasures.cpp
Generated by
1.8.17