Crossfire Server, Branches 1.12  R18729
cre.cpp
Go to the documentation of this file.
1 extern "C" {
2 #include "global.h"
3 #include "libproto.h"
4 }
5 
6 #include <Qt>
7 #include <QApplication>
8 #include <QCoreApplication>
9 
10 #include <CREMainWindow.h>
11 
12 #include "CREPixmap.h"
13 
14 int main(int argc, char** argv)
15 {
16  QCoreApplication::setOrganizationName("The Legendary Team of Ailesse");
17  QCoreApplication::setApplicationName("CRE");
18  QApplication app(argc, argv);
19 
20  init_globals();
21  init_library();
24  init_formulae();
26 
28 
29  CREMainWindow win;
30  win.show();
31 
32  return app.exec();
33 }
34 
35 #ifndef DOXYGEN_SHOULD_SKIP_THIS
36 
37 extern "C"
38 {
39 
44 void draw_ext_info(int, int, const object *, uint8, uint8, const char *txt, const char *)
45 {
46  fprintf(logfile, "%s\n", txt);
47 }
48 
50  int, int, const object *, uint8,
51  uint8,
52  const char *,
53  const char *old_format,
54  ...)
55 {
56  va_list ap;
57  va_start(ap, old_format);
58  vfprintf(logfile, old_format, ap);
59  va_end(ap);
60 }
61 
62 
63 void ext_info_map(int, const mapstruct *, uint8, uint8, const char *, const char *str2)
64 {
65  fprintf(logfile, "ext_info_map: %s\n", str2);
66 }
67 
68 void move_firewall(object *)
69 {
70 }
71 
72 void emergency_save(int)
73 {
74 }
75 
76 void clean_tmp_files(void)
77 {
78 }
79 
80 void esrv_send_item(object *, object *)
81 {
82 }
83 
84 void dragon_ability_gain(object *, int, int)
85 {
86 }
87 
89 {
90 }
91 
92 object *find_skill_by_number(object *, int)
93 {
94  return NULL;
95 }
96 
97 void esrv_del_item(player *, int)
98 {
99 }
100 
101 void esrv_update_item(int, object *, object *)
102 {
103 }
104 
106 {
107 }
108 
109 void monster_check_apply(object *, object *)
110 {
111 }
112 
113 void trap_adjust(object *, int)
114 {
115 }
116 
117 int execute_event(object *, int , object *, object *, const char *, int )
118 {
119  return 0;
120 }
121 
122 int execute_global_event(int , ...)
123 {
124  return 0;
125 }
126 
127 
128 int auto_apply (object *op) {
129  object *tmp = NULL, *tmp2;
130  int i;
131 
132  switch(op->type) {
133  case SHOP_FLOOR:
134  if (!HAS_RANDOM_ITEMS(op)) return 0;
135  do {
136  i=10; /* let's give it 10 tries */
137  while((tmp=generate_treasure(op->randomitems,
138  op->stats.exp?(int)op->stats.exp:MAX(op->map->difficulty, 5)))==NULL&&--i);
139  if(tmp==NULL)
140  return 0;
141  if(QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) {
142  free_object(tmp);
143  tmp = NULL;
144  }
145  } while(!tmp);
146  tmp->x=op->x;
147  tmp->y=op->y;
148  SET_FLAG(tmp,FLAG_UNPAID);
149  insert_ob_in_map(tmp,op->map,NULL,0);
151  identify(tmp);
152  break;
153 
154  case TREASURE:
156  return 0;
157  while ((op->stats.hp--)>0)
159  op->stats.exp ? (int)op->stats.exp :
160  op->map == NULL ? 14: op->map->difficulty,0);
161 
162  /* If we generated an object and put it in this object inventory,
163  * move it to the parent object as the current object is about
164  * to disappear. An example of this item is the random_ *stuff
165  * that is put inside other objects.
166  */
167  for (tmp=op->inv; tmp; tmp=tmp2) {
168  tmp2 = tmp->below;
169  remove_ob(tmp);
170  if (op->env) insert_ob_in_ob(tmp, op->env);
171  else free_object(tmp);
172  }
173  remove_ob(op);
174  free_object(op);
175  break;
176  }
177  return tmp ? 1 : 0;
178 }
179 
181 {
182 }
183 
184 }
185 #endif
EXTERN FILE * logfile
Definition: global.h:220
Definition: player.h:146
#define FLAG_DAMNED
Definition: define.h:614
#define FLAG_UNPAID
Definition: define.h:532
#define SET_FLAG(xyz, p)
Definition: define.h:510
struct treasureliststruct * randomitems
Definition: object.h:236
void init_globals(void)
Definition: init.c:263
sint64 exp
Definition: living.h:88
void init_library(void)
Definition: init.c:201
sint16 x
Definition: object.h:179
void esrv_del_item(player *, int)
Definition: cre.cpp:97
void monster_check_apply(object *, object *)
Definition: cre.cpp:109
sint16 hp
Definition: living.h:81
void init_formulae(void)
Definition: recipe.c:159
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
Definition: treasure.c:499
void emergency_save(int)
Definition: cre.cpp:72
void remove_ob(object *op)
Definition: object.c:1515
#define SHOP_FLOOR
Definition: define.h:230
void esrv_update_spells(player *)
Definition: cre.cpp:105
void fix_auto_apply(mapstruct *)
Definition: cre.cpp:180
struct mapdef * map
Definition: object.h:155
void identify(object *op)
Definition: item.c:1447
int auto_apply(object *op)
Definition: cre.cpp:128
struct obj * env
Definition: object.h:151
struct obj * below
Definition: object.h:145
void load_treasures(void)
Definition: treasure.c:224
uint16 difficulty
Definition: map.h:364
#define FLAG_IS_A_TEMPLATE
Definition: define.h:671
unsigned char uint8
Definition: global.h:75
sint16 y
Definition: object.h:179
void read_client_images(void)
Definition: image.c:471
#define MAX(x, y)
Definition: define.h:70
void clean_tmp_files(void)
Definition: cre.cpp:76
object * find_skill_by_number(object *, int)
Definition: cre.cpp:92
#define QUERY_FLAG(xyz, p)
Definition: define.h:514
#define CLEAR_FLAG(xyz, p)
Definition: define.h:512
void set_darkness_map(mapstruct *)
Definition: cre.cpp:88
object * insert_ob_in_ob(object *op, object *where)
Definition: object.c:2510
void trap_adjust(object *, int)
Definition: cre.cpp:113
object * insert_ob_in_map(object *op, mapstruct *m, object *originator, int flag)
Definition: object.c:1992
#define FLAG_CURSED
Definition: define.h:613
void esrv_send_item(object *, object *)
Definition: cre.cpp:80
void esrv_update_item(int, object *, object *)
Definition: cre.cpp:101
#define FLAG_AUTO_APPLY
Definition: define.h:546
living stats
Definition: object.h:219
int main(int argc, char **argv)
Definition: cre.cpp:14
int execute_event(object *, int, object *, object *, const char *, int)
Definition: cre.cpp:117
void dragon_ability_gain(object *, int, int)
Definition: cre.cpp:84
#define TREASURE
Definition: define.h:116
void draw_ext_info(int, int, const object *, uint8, uint8, const char *txt, const char *)
Definition: cre.cpp:44
struct obj * inv
Definition: object.h:148
void move_firewall(object *)
Definition: cre.cpp:68
static void init()
Definition: CREPixmap.cpp:17
object * generate_treasure(treasurelist *t, int difficulty)
Definition: treasure.c:524
void free_object(object *ob)
Definition: object.c:1238
Definition: map.h:346
void ext_info_map(int, const mapstruct *, uint8, uint8, const char *, const char *str2)
Definition: cre.cpp:63
void draw_ext_info_format(int, int, const object *, uint8, uint8, const char *, const char *old_format,...)
Definition: cre.cpp:49
int execute_global_event(int,...)
Definition: cre.cpp:122
#define HAS_RANDOM_ITEMS(op)
Definition: define.h:470
uint8 type
Definition: object.h:189
void init_artifacts(void)
Definition: treasure.c:1539