Crossfire Server, Trunk  R20513
bwp.c
Go to the documentation of this file.
1 /*
2  * bwp - build wiki pages
3  *
4  * This program will sort out all monster archetypes and print wiki pages
5  * for them, named 'a' through 'z'. It uses some *_template subroutines taken
6  * from Ryo's mapper.c. It should compile if installed in server/trunk/utils.
7  * Please direct all suggestions or corrections to aaron@baugher.biz (or
8  * Mhoram on #crossfire).
9  *
10  * Compile command: gcc -g -O0 bwp.c -I../include ../common/libcross.a ../socket/libsocket.a -o bwp -lz -lcrypt -lm
11  */
12 
13 /*
14  * CrossFire, A Multiplayer game for X-windows
15  *
16  * Copyright (C) 2002-2006 Mark Wedel & Crossfire Development Team
17  * Copyright (C) 1992 Frank Tore Johansen
18  *
19  * This program is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 2 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; if not, write to the Free Software
31  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32  *
33  * The authors can be reached via e-mail at crossfire-devel@real-time.com
34  */
35 
36 #define LO_NEWFILE 2
37 #define MAX_SIZE 64
38 #define NA "n/a"
39 
40 #include <time.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <global.h>
44 
45 char *monster_page_head; /* Head of wiki page of monsters */
46 char *monster_page_foot; /* Foot of wiki page of monsters */
47 char *monster_entry; /* A single monster entry */
48 char *monster_canuse_row; /* Can_use table row */
49 char *monster_protected_row; /* Protected table row */
50 char *monster_vulnerable_row; /* Vulnerable table row */
51 char *monster_special_row; /* Special table row */
52 char *monster_attack_row; /* Attack types table row */
53 char *monster_lore_row; /* Lore table row */
54 
55 typedef struct string_array {
57  char **item;
58 } String_Array;
59 
69 const char *const flag_names[NUM_FLAGS+1] = {
70  "alive", "wiz", NULL, NULL, "was_wiz", "applied", "unpaid",
71  "can_use_shield", "no_pick", "client_anim_sync", "client_anim_random", /* 10 */
72  "is_animated", NULL /* slow_move */,
73  NULL /* flying */, "monster", "friendly", "generator",
74  "is_thrown", "auto_apply", "treasure", "player sold", /* 20 */
75  "see_invisible", "can_roll", "overlay_floor",
76  "is_turnable", NULL /* walk_off */, NULL /* fly_on */,
77  NULL /*fly_off*/, "is_used_up", "identified", "reflecting", /* 30 */
78  "changing", "splitting", "hitback", "startequip",
79  "blocksview", "undead", "scared", "unaggressive",
80  "reflect_missile", "reflect_spell", /* 40 */
81  "no_magic", "no_fix_player", "is_lightable", "tear_down",
82  "run_away", NULL /*pass_thru */, NULL /*can_pass_thru*/,
83  "pick_up", "unique", "no_drop", /* 50 */
84  NULL /* wizcast*/, "can_cast_spell", "can_use_scroll", "can_use_range",
85  "can_use_bow", "can_use_armour", "can_use_weapon",
86  "can_use_ring", "has_ready_range", "has_ready_bow", /* 60 */
87  "xrays", NULL, "is_floor", "lifesave", "no_strength", "sleep",
88  "stand_still", "random_movement", "only_attack", "confused", /* 70 */
89  "stealth", NULL, NULL, "cursed", "damned",
90  "see_anywhere", "known_magical", "known_cursed",
91  "can_use_skill", "been_applied", /* 80 */
92  "has_ready_scroll", NULL, NULL,
93  NULL, "make_invisible", "inv_locked", "is_wooded",
94  "is_hilly", "has_ready_skill", "has_ready_weapon", /* 90 */
95  "no_skill_ident", "is_blind", "can_see_in_dark", "is_cauldron",
96  "is_dust", "no_steal", "one_hit", NULL, "berserk", "neutral", /* 100 */
97  "no_attack", "no_damage", NULL, NULL, "activate_on_push",
98  "activate_on_release", "is_water", "use_content_on_gen", NULL, "is_buildable", /* 110 */
99  NULL, "blessed", "known_blessed"
100 };
101 
112 static char *cat_template(char *source, char *add) {
113  if (!source)
114  return add;
115  source = realloc(source, strlen(source)+strlen(add)+1);
116  strcat(source, add);
117  free(add);
118  return source;
119 }
120 
131 static int read_template(const char *name, char **buffer) {
132  FILE *file;
133  size_t size;
134  struct stat info;
135 
136  if (stat(name, &info)) {
137  printf("Couldn't stat template %s!\n", name);
138  return 1;
139  }
140 
141  (*buffer) = calloc(1, info.st_size+1);
142  if (!(*buffer)) {
143  printf("Template %s calloc failed!\n", name);
144  return 1;
145  }
146 
147  if (info.st_size == 0) {
148  (*buffer)[0] = '\0';
149  return 0;
150  }
151 
152  file = fopen(name, "rb");
153  if (!file) {
154  printf("Couldn't open template %s!\n", name);
155  free(*buffer);
156  return 1;
157  }
158  if (fread(*buffer, info.st_size, 1, file) != 1) {
159  printf("Couldn't read template %s!\n", name);
160  free(*buffer);
161  fclose(file);
162  return 1;
163  }
164  fclose(file);
165  return 0;
166 }
167 
185 static char *do_template(const char *template, const char **vars, const char **values) {
186  int count = 0;
187  const char *sharp = template;
188  int maxlen = 0;
189  int var = 0;
190  char *result;
191  char *current_result;
192  const char *end;
193 
194  while ((sharp = strchr(sharp, '#')) != NULL) {
195  sharp++;
196  count++;
197  }
198  if (!count)
199  return strdup(template);
200  if (count%2) {
201  printf("Malformed template, mismatched #!\n");
202  return strdup(template);
203  }
204 
205  while (vars[var] != NULL) {
206  if (strlen(values[var]) > maxlen)
207  maxlen = strlen(values[var]);
208  var++;
209  }
210  result = calloc(1, strlen(template)+maxlen*(count/2)+1);
211  if (!result)
212  return NULL;
213  current_result = result;
214 
215  sharp = template;
216  while ((sharp = strchr(sharp, '#')) != NULL) {
217  end = strchr(sharp+1, '#');
218  strncpy(current_result, template, sharp-template);
219  if (end == sharp+1) {
220  strcat(current_result, "#");
221  } else {
222  current_result = current_result+strlen(current_result);
223  var = 0;
224  while (vars[var] != 0 && strncmp(vars[var], sharp+1, end-sharp-1))
225  var++;
226  if (vars[var] == 0)
227  printf("Wrong tag: %s\n", sharp);
228  else
229  strcpy(current_result, values[var]);
230  }
231  current_result = current_result+strlen(current_result);
232  sharp = end+1;
233  template = sharp;
234  }
235  strcat(current_result, template);
236  return result;
237 }
238 
239 /**** Mhoram's code starts here *****/
240 
253 static void free_if_used(char *p) {
254  if (p && strlen(p) > 0) {
255  free(p);
256  }
257 }
258 
271 static int sortbyname(const void *a, const void *b) {
272  return (strcasecmp(*(const char **)a, *(const char **)b));
273 }
274 
288 static int sort_archetypes(const void *a, const void *b) {
289  archetype *aa;
290  archetype *bb;
291 
292  aa = *(archetype **)a;
293  bb = *(archetype **)b;
294 
295  return (strcasecmp(aa->clone.name, bb->clone.name));
296 }
297 
310 void push(String_Array *array, const char *string) {
311  int16_t i = array->count;
312 
313  array->item[i] = strdup_local(string);
314  array->count++;
315 }
316 
325 void free_data(String_Array *array) {
326  int item;
327 
328  for (item = 0; item < array->count; item++)
329  free(array->item[item]);
330  free(array->item);
331  array->item = NULL;
332 }
333 
344 const char *join_with_comma(String_Array *array) {
345  char *newtext;
346  int i;
347 
348  newtext = calloc(1, 1);
349  qsort(array->item, array->count, sizeof(char *), sortbyname);
350  for (i = 0; i < array->count; i++) {
351  if (i) {
352  newtext = realloc(newtext, strlen(newtext)+strlen(", ")+1);
353  newtext = strncat(newtext, ", ", 2);
354  }
355  newtext = realloc(newtext, strlen(newtext)+strlen(array->item[i])+1);
356  newtext = strncat(newtext, array->item[i], strlen(array->item[i]));
357  }
358  return newtext;
359 }
360 
361 int main(int argc, char *argv[]) {
362 
363  archetype *at;
364  int archnum = 0;
365  archetype *monster[4000];
366  int i;
367  char letter;
368  char last_letter;
369  char *wiki_page = NULL;
370  char *monster_entries = NULL;
371 
372  FILE *fp = NULL;
373  FILE *image_list;
374  char image_list_path[128];
375  char wikifile[128];
376  char *template;
377 
378  const char *wikidir = "/tmp"; /* Should change this to come from command line? */
379 
380  init_globals();
381  init_library();
382  init_archetypes();
383  init_artifacts();
384  init_formulae();
385  init_readable();
386 
387  init_gods();
388 
389  /* Initialize templates */
390  if (read_template("templates/wiki/monster_page_head", &monster_page_head))
391  return;
392  if (read_template("templates/wiki/monster_page_foot", &monster_page_foot))
393  return;
394  if (read_template("templates/wiki/monster_entry", &monster_entry))
395  return;
396  if (read_template("templates/wiki/monster_canuse_row", &monster_canuse_row))
397  return;
398  if (read_template("templates/wiki/monster_protected_row", &monster_protected_row))
399  return;
400  if (read_template("templates/wiki/monster_vulnerable_row", &monster_vulnerable_row))
401  return;
402  if (read_template("templates/wiki/monster_special_row", &monster_special_row))
403  return;
404  if (read_template("templates/wiki/monster_attack_row", &monster_attack_row))
405  return;
406  if (read_template("templates/wiki/monster_lore_row", &monster_lore_row))
407  return;
408  sprintf(image_list_path, "%s/image_list", wikidir);
409  image_list = fopen(image_list_path, "w");
410  if (!image_list) {
411  LOG(llevError, "Unable to open image list file!\n");
412  exit(1);
413  }
414 
415  /* Pick out the monster archetypes and sort them into an array */
416  for (at = first_archetype; at != NULL; at = at->next) {
417  if (QUERY_FLAG(&at->clone, FLAG_MONSTER)
418  && QUERY_FLAG(&at->clone, FLAG_ALIVE)) {
419  monster[archnum++] = at;
420  }
421  }
422  printf("Sorting...");
423  /* Calling qsort on monster, which is archetype** */
424  qsort(&monster[0], archnum, sizeof(archetype *), sort_archetypes);
425  printf("done. %i items found\n", archnum);
426 
427  last_letter = '\0';
428 
429  for (i = 0; i < archnum; i++) {
430  at = monster[i];
431  if (at) {
432  const char *key[16] = { NULL, };
433  const char *val[16] = { NULL, };
434  char buf[16][MAX_BUF];
435  int keycount = 0;
436  int res;
437 
438  letter = tolower(at->clone.name[0]);
439 
440  LOG(llevInfo, "Doing archetype %s\n", at->name);
441 
442  if (letter != last_letter) { /* New letter, new file */
443  if (fp) {
444  keycount = 0;
445  key[keycount] = NULL;
446  template = do_template(monster_page_foot, key, val);
447  res = fprintf(fp, "%s", template);
448  free(template);
449  template = NULL;
450  if (res < 0) {
451  LOG(llevError, "Unable to write to file!\n");
452  }
453  fclose(fp);
454  }
455 
456  snprintf(wikifile, sizeof(wikifile), "%s/%c", wikidir, letter);
457  fp = fopen(wikifile, "w");
458  if (!fp) {
459  fprintf(stderr, "Unable to write to wiki file!\n");
460  exit(1);
461  }
462 
463  char letterindex[256] = "";
464  char letterindexnext[7];
465  char li;
466  letterindexnext[0] = '\0';
467  for (li = 'a'; li <= 'z'; li++) {
468  char *p;
469 
470  if (li == letter) {
471  sprintf(letterindexnext, "%c ", toupper(li));
472  } else {
473  sprintf(letterindexnext, "[[%c]] ", toupper(li));
474  }
475  p = strchr(letterindex, '\0');
476  snprintf(p, letterindex+sizeof(letterindex)-p, "%s", letterindexnext);
477  }
478 
479  keycount = 0;
480  key[keycount] = "LETTER";
481  sprintf(buf[keycount], "%c", toupper(letter));
482  val[keycount++] = buf[keycount];
483  key[keycount] = "LETTERINDEX";
484  val[keycount++] = letterindex;
485  key[keycount] = NULL;
486  template = do_template(monster_page_head, key, val);
487  res = fprintf(fp, template);
488  free(template);
489  if (res < 0) {
490  LOG(llevError, "Unable to write to file!");
491  }
492  last_letter = letter;
493  }
494 
495  /* add a monster entry */
496  char *canuse_row;
497  char *protected_row;
498  char *vulnerable_row;
499  char *special_row;
500  char *attack_row;
501  char *lore_row;
502  const int CANUSE_LENGTH = 16;
503  String_Array canuse;
504  String_Array resist;
505  String_Array vulner;
506  String_Array attack;
507  String_Array special;
508  /* Some flags that seemed useful; may need to add to this list.
509  * *special_names[] is used because some of the names in
510  * define.h are a bit awkward. Last one is negative to mark end.
511  */
512  const int8_t special_flags[] = { 21, 93, 52, 38, 13, 32, 61, -1 };
513  const char *special_names[] = {
514  "see invisible",
515  "see in dark",
516  "spellcaster",
517  "unaggressive",
518  "flying",
519  "splitting",
520  "x-ray vision"
521  };
522  int j;
523 
524  canuse.item = calloc((CANUSE_LENGTH+1), sizeof(const char *));
525  resist.item = calloc((NROFATTACKS+1), sizeof(const char *));
526  vulner.item = calloc((NROFATTACKS+1), sizeof(const char *));
527  attack.item = calloc((NROFATTACKS+1), sizeof(const char *));
528  special.item = calloc((NROFATTACKS+1), sizeof(const char *));
529 
530  /* Do lore row */
531  if (at->clone.lore) {
532  key[keycount] = "LORE";
533  key[keycount+1] = NULL;
534  val[keycount] = at->clone.lore;
535  keycount++;
536  lore_row = do_template(monster_lore_row, key, val);
537  } else
538  lore_row = strdup("");
539 
540  /* Do canuse row */
541  canuse.count = 0;
542  keycount = 0;
543  for (j = 1; j <= NUM_FLAGS; j++) {
544  if (QUERY_FLAG(&at->clone, j)
545  && flag_names[j]
546  && !strncmp(flag_names[j], "can_use_", 8)) {
547  push(&canuse, flag_names[j]+8);
548  }
549  }
550  if (canuse.count) {
551  key[keycount] = "CANUSE";
552  key[keycount+1] = NULL;
553  val[keycount] = join_with_comma(&canuse);
554  canuse_row = do_template(monster_canuse_row, key, val);
555  free(val[keycount]);
556  } else
557  canuse_row = strdup("");
558 
559  /* Do protected/vulnerable rows */
560  resist.count = 0;
561  vulner.count = 0;
562  for (j = 0; j <= NROFATTACKS; j++) {
563  if (at->clone.resist[j] && attacktype_desc[j]) {
564  char rowtext[32];
565 
566  if (at->clone.resist[j] < 0) {
567  sprintf(rowtext, "%s %i", attacktype_desc[j], at->clone.resist[j]);
568  push(&vulner, rowtext);
569  } else {
570  sprintf(rowtext, "%s +%i", attacktype_desc[j], at->clone.resist[j]);
571  push(&resist, rowtext);
572  }
573  }
574  }
575  keycount = 0;
576  if (resist.count) {
577  key[keycount] = "PROTECTED";
578  key[keycount+1] = NULL;
579  val[keycount] = join_with_comma(&resist);
580  protected_row = do_template(monster_protected_row, key, val);
581  free(val[keycount]);
582  } else
583  protected_row = strdup("");
584 
585  keycount = 0;
586  if (vulner.count) {
587  key[keycount] = "VULNERABLE";
588  key[keycount+1] = NULL;
589  val[keycount] = join_with_comma(&vulner);
590  vulnerable_row = do_template(monster_vulnerable_row, key, val);
591  free(val[keycount]);
592  } else
593  vulnerable_row = strdup("");
594 
595  /* Do attacktype row */
596  attack.count = 0;
597  keycount = 0;
598  val[keycount] = NULL;
599  for (j = 0; j <= NROFATTACKS; j++) {
600  if (at->clone.attacktype&(1U<<j)) {
601  push(&attack, attacktype_desc[j]);
602  }
603  }
604  if (attack.count) {
605  key[keycount] = "ATTACKS";
606  key[keycount+1] = NULL;
607  val[keycount] = join_with_comma(&attack);
608  attack_row = do_template(monster_attack_row, key, val);
609  free(val[keycount]);
610  } else
611  attack_row = strdup("");
612 
613  /* Do special row */
614  special.count = 0;
615  keycount = 0;
616  val[keycount] = NULL;
617  for (j = 0; special_flags[j] >= 0; j++) {
618  if (QUERY_FLAG(&at->clone, special_flags[j])) {
619  push(&special, special_names[j]);
620  }
621  }
622  if (special.count) {
623  key[keycount] = "SPECIAL";
624  key[keycount+1] = NULL;
625  val[keycount] = join_with_comma(&special);
626  special_row = do_template(monster_special_row, key, val);
627  free(val[keycount]);
628  } else
629  special_row = strdup("");
630 
631  keycount = 0;
632  key[keycount] = "CANUSEROW";
633  val[keycount++] = canuse_row;
634  key[keycount] = "PROTECTEDROW";
635  val[keycount++] = protected_row;
636  key[keycount] = "VULNERABLEROW";
637  val[keycount++] = vulnerable_row;
638  key[keycount] = "SPECIALROW";
639  val[keycount++] = attack_row;
640  key[keycount] = "ATTACKROW";
641  val[keycount++] = special_row;
642  key[keycount] = "LOREROW";
643  val[keycount++] = lore_row;
644  key[keycount] = "XP";
645  sprintf(buf[keycount], "%li", at->clone.stats.exp);
646  val[keycount++] = buf[keycount];
647  key[keycount] = "HP";
648  sprintf(buf[keycount], "%i", at->clone.stats.hp);
649  val[keycount++] = buf[keycount];
650  key[keycount] = "AC";
651  sprintf(buf[keycount], "%i", at->clone.stats.ac);
652  val[keycount++] = buf[keycount];
653  key[keycount] = "NAME";
654  val[keycount++] = at->clone.name;
655  key[keycount] = "RACE";
656  if (at->clone.race) {
657  val[keycount++] = at->clone.race;
658  } else {
659  val[keycount++] = NA;
660  }
661  if (at->clone.face->name) {
662  key[keycount] = "FACE";
663  sprintf(buf[keycount], "{{http://aaron.baugher.biz/images/cf/%s.png}}", at->clone.face->name);
664  val[keycount++] = buf[keycount];
665  sprintf(buf[keycount], "%s.png\n", at->clone.face->name);
666  fprintf(image_list, buf[keycount]);
667  }
668 /* Plan to add generator face too, when I decide how */
669  key[keycount] = "GENFACE";
670  val[keycount++] = "";
671  key[keycount] = NULL;
672 
673  template = do_template(monster_entry, key, val);
674  fprintf(fp, template);
675  free(template);
676  template = NULL;
677 
678  free_data(&canuse);
679  free_data(&resist);
680  free_data(&vulner);
681  free_data(&attack);
682  free_data(&special);
683  free(canuse_row);
684  free(protected_row);
685  free(vulnerable_row);
686  free(attack_row);
687  free(special_row);
688  free(lore_row);
689  } else {
690  LOG(llevError, "Something is very wrong.\n");
691  }
692  }
693  fclose(image_list);
694 }
695 
696 void set_map_timeout(void) {
697  /* doesn't need to do anything */
698 }
699 
700 #include <global.h>
701 
702 /* some plagarized code from apply.c--I needed just these two functions
703  without all the rest of the junk, so.... */
704 int apply_auto(object *op) {
705  object *tmp = NULL;
706  int i;
707 
708  switch (op->type) {
709  case SHOP_FLOOR:
710  if (!HAS_RANDOM_ITEMS(op))
711  return 0;
712  do {
713  i = 10; /* let's give it 10 tries */
714  while ((tmp = generate_treasure(op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i)
715  ;
716  if (tmp == NULL)
717  return 0;
718  if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) {
720  tmp = NULL;
721  }
722  } while (!tmp);
723 
724  SET_FLAG(tmp, FLAG_UNPAID);
725  object_insert_in_map_at(tmp, op->map, NULL, 0, op->x, op->y);
727  tmp = identify(tmp);
728  break;
729 
730  case TREASURE:
731  if (HAS_RANDOM_ITEMS(op))
732  while ((op->stats.hp--) > 0)
733  create_treasure(op->randomitems, op, GT_ENVIRONMENT, op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
734  object_remove(op);
736  break;
737  }
738 
739  return tmp ? 1 : 0;
740 }
741 
742 /* apply_auto_fix goes through the entire map (only the first time
743  * when an original map is loaded) and performs special actions for
744  * certain objects (most initialization of chests and creation of
745  * treasures and stuff). Calls apply_auto if appropriate.
746  */
748  object *tmp, *above = NULL;
749  int x, y;
750 
751  for (x = 0; x < MAP_WIDTH(m); x++)
752  for (y = 0; y < MAP_HEIGHT(m); y++)
753  for (tmp = GET_MAP_OB(m, x, y); tmp != NULL; tmp = above) {
754  above = tmp->above;
755 
756  if (QUERY_FLAG(tmp, FLAG_AUTO_APPLY))
757  apply_auto(tmp);
758  else if (tmp->type == TREASURE) {
759  if (HAS_RANDOM_ITEMS(tmp))
760  while ((tmp->stats.hp--) > 0)
761  create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
762  }
763  if (tmp
764  && tmp->arch
765  && tmp->type != PLAYER
766  && tmp->type != TREASURE
767  && tmp->randomitems) {
768  if (tmp->type == CONTAINER) {
769  if (HAS_RANDOM_ITEMS(tmp))
770  while ((tmp->stats.hp--) > 0)
771  create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
772  } else if (HAS_RANDOM_ITEMS(tmp)) {
773  create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
774  if (QUERY_FLAG(tmp, FLAG_MONSTER)) {
776  }
777  }
778  }
779  }
780  for (x = 0; x < MAP_WIDTH(m); x++)
781  for (y = 0; y < MAP_HEIGHT(m); y++)
782  for (tmp = GET_MAP_OB(m, x, y); tmp != NULL; tmp = tmp->above)
783  if (tmp->above
784  && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
785  check_trigger(tmp, tmp->above);
786 }
787 
788 #ifndef DOXYGEN_SHOULD_SKIP_THIS
789 
795 void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *txt) {
796  fprintf(logfile, "%s\n", txt);
797 }
798 
799 void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format, ...) {
800  va_list ap;
801  va_start(ap, format);
802  vfprintf(logfile, format, ap);
803  va_end(ap);
804 }
805 
806 void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1) {
807  fprintf(logfile, "ext_info_map: %s\n", str1);
808 }
809 
810 void move_firewall(object *ob) {
811 }
812 
813 void emergency_save(int x) {
814 }
815 
816 void clean_tmp_files(void) {
817 }
818 
819 void esrv_send_item(object *ob, object *obx) {
820 }
821 
822 void dragon_ability_gain(object *ob, int x, int y) {
823 }
824 
826 }
827 
828 object *find_skill_by_number(object *who, int skillno) {
829  return NULL;
830 }
831 
832 void esrv_del_item(player *pl, object *ob) {
833 }
834 
836 }
837 
838 int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix) {
839  return 0;
840 }
841 
842 int execute_global_event(int eventcode, ...) {
843  return 0;
844 }
845 #endif /* dummy DOXYGEN_SHOULD_SKIP_THIS */
EXTERN FILE * logfile
Used by server/daemon.c.
Definition: global.h:144
char * monster_page_foot
Definition: bwp.c:46
Error, serious thing.
Definition: logger.h:11
One player.
Definition: player.h:92
void set_darkness_map(mapstruct *m)
Set the darkness level for a map, based on the time of the day.
Definition: bwp.c:825
void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Writes to everyone on the specified map.
Definition: bwp.c:806
#define FLAG_DAMNED
The object is very cursed.
Definition: define.h:318
#define FLAG_UNPAID
Object hasn&#39;t been paid for yet.
Definition: define.h:236
int8_t ac
Armour Class, how hard to hit, the lower the better.
Definition: living.h:37
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *txt)
Those are dummy functions defined to resolve all symboles.
Definition: bwp.c:795
Information.
Definition: logger.h:12
void move_firewall(object *ob)
Move for FIREWALL.
Definition: bwp.c:810
void dragon_ability_gain(object *ob, int x, int y)
When a dragon-player gains a new stage of evolution, he gets some treasure.
Definition: bwp.c:822
void set_map_timeout(void)
Definition: bwp.c:696
const char * race
Human, goblin, dragon, etc.
Definition: object.h:318
#define SET_FLAG(xyz, p)
Definition: define.h:223
unsigned char uint8_t
Definition: win32.h:161
static int read_template(const char *name, char **buffer)
Reads a file in memory.
Definition: bwp.c:131
#define strdup_local
Definition: compat.h:25
#define NA
Definition: bwp.c:38
struct treasureliststruct * randomitems
Items to be generated.
Definition: object.h:385
char * monster_attack_row
Definition: bwp.c:52
const char *const flag_names[NUM_FLAGS+1]
This is a list of pointers that correspond to the FLAG_.
Definition: bwp.c:69
#define MAP_HEIGHT(m)
Map height.
Definition: map.h:80
object clone
An object from which to do object_copy()
Definition: object.h:470
char * monster_entry
Definition: bwp.c:47
void init_archetypes(void)
Initialises the internal linked list of archetypes (read from file).
Definition: arch.c:182
void init_globals(void)
Initialises all global variables.
Definition: init.c:272
int execute_global_event(int eventcode,...)
Definition: bwp.c:842
int64_t exp
Experience.
Definition: living.h:46
struct obj * above
Pointer to the object stacked above this one.
Definition: object.h:288
void init_library(void)
It is vital that init_library() is called by any functions using this library.
Definition: init.c:201
See Button Trigger.
Definition: object.h:132
int16_t count
Definition: bwp.c:56
void esrv_update_spells(player *pl)
This looks for any spells the player may have that have changed their stats.
Definition: bwp.c:835
Global type definitions and header inclusions.
int apply_auto(object *op)
Map was just loaded, handle op&#39;s initialization.
Definition: bwp.c:704
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
Definition: object.h:465
int16_t hp
Hit Points.
Definition: living.h:39
void init_formulae(void)
Builds up the lists of formula from the file in the libdir.
Definition: recipe.c:161
void create_treasure(treasurelist *t, object *op, int flag, int difficulty, int tries)
This calls the appropriate treasure creation function.
Definition: treasure.c:490
void free_data(String_Array *array)
Frees the item&#39;s data of specified String_Array.
Definition: bwp.c:325
const char * lore
Obscure information about this object, to get put into books and the like.
Definition: object.h:323
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
Definition: object.c:1368
const char * name
Face name, as used by archetypes and such.
Definition: face.h:20
int16_t y
Position in the map for this object.
Definition: object.h:326
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
Definition: object.c:1921
#define FLAG_ALIVE
Object can fight (or be fought)
Definition: define.h:230
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...)
Sends message to player(s).
Definition: bwp.c:799
signed short int16_t
Definition: win32.h:160
See Treasure.
Definition: object.h:110
struct mapdef * map
Pointer to the map in which this object is present.
Definition: object.h:297
void monster_check_apply_all(object *monster)
Calls monster_check_apply() for all inventory objects.
Definition: monster.c:1757
#define snprintf
Definition: win32.h:46
static int sort_archetypes(const void *a, const void *b)
Sort archetypes alphabetically.
Definition: bwp.c:288
const char * join_with_comma(String_Array *array)
Joins strings with a comma and space.
Definition: bwp.c:344
char * monster_protected_row
Definition: bwp.c:49
char ** item
Definition: bwp.c:57
const char * name
The name of the object, obviously...
Definition: object.h:311
static char * cat_template(char *source, char *add)
Concatenates a string, and free concatenated string.
Definition: bwp.c:112
#define NUM_FLAGS
Should always be equal to the last defined flag.
Definition: define.h:385
char * monster_canuse_row
Definition: bwp.c:48
void apply_auto_fix(mapstruct *m)
Go through the entire map (only the first time when an original map is loaded) and performs special a...
Definition: bwp.c:747
#define QUERY_FLAG(xyz, p)
Definition: define.h:225
#define CLEAR_FLAG(xyz, p)
Definition: define.h:224
void esrv_send_item(object *ob, object *obx)
Sends item&#39;s info to player.
Definition: bwp.c:819
EXTERN const char *const attacktype_desc[NROFATTACKS]
Definition: attack.h:138
void init_readable(void)
Initialize linked lists utilized by message functions in tailor_readable_ob()
Definition: readable.c:1005
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
object * find_skill_by_number(object *who, int skillno)
This returns the skill pointer of the given name (the one that accumulates exp, has the level...
Definition: bwp.c:828
int16_t x
Definition: object.h:326
char * monster_lore_row
Definition: bwp.c:53
int main(int argc, char *argv[])
Definition: bwp.c:361
#define tolower(C)
Simple macro to convert a letter to lowercase.
Definition: c_new.c:29
See Container.
Definition: object.h:231
uint16_t difficulty
What level the player should be to play here.
Definition: map.h:343
static const flag_definition flags[]
Flag mapping.
int16_t resist[NROFATTACKS]
Resistance adjustments for attacks.
Definition: object.h:341
int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix)
Definition: bwp.c:838
#define FLAG_CURSED
The object is cursed.
Definition: define.h:317
See Player.
Definition: object.h:107
struct string_array String_Array
void esrv_del_item(player *pl, object *ob)
Tells the client to delete an item.
Definition: bwp.c:832
#define FLAG_AUTO_APPLY
Will be applied when created.
Definition: define.h:250
uint32_t attacktype
Bitmask of attacks this object does.
Definition: object.h:342
void emergency_save(int x)
Save all players.
Definition: bwp.c:813
signed char int8_t
Type definitions for fixed-size integer types.
Definition: win32.h:158
char * monster_vulnerable_row
Definition: bwp.c:50
void clean_tmp_files(void)
Remove temporary map files.
Definition: bwp.c:816
living stats
Str, Con, Dex, etc.
Definition: object.h:368
struct archt * arch
Pointer to archetype.
Definition: object.h:412
See Shop Floor.
Definition: object.h:183
#define MAP_WIDTH(m)
Map width.
Definition: map.h:78
uint8_t type
PLAYER, BULLET, etc.
Definition: object.h:338
struct archt * next
Next archetype in a linked list.
Definition: object.h:467
#define NROFATTACKS
Definition: attack.h:17
static void free_if_used(char *p)
Frees memory if the pointer was ever given a string.
Definition: bwp.c:253
void init_gods(void)
This takes a look at all of the archetypes to find the objects which correspond to the GODS (type GOD...
Definition: holy.c:53
object * identify(object *op)
Identifies an item.
Definition: item.c:1437
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
Definition: map.h:172
int strcasecmp(const char *s1, const char *s2)
Case-insensitive comparaison of strings.
Definition: porting.c:256
#define FLAG_MONSTER
Will attack players.
Definition: define.h:245
char * strdup(const char *str)
Portable implementation of strdup(3).
Definition: porting.c:200
char * monster_special_row
Definition: bwp.c:51
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.c:51
static int sortbyname(const void *a, const void *b)
Sort values alphabetically.
Definition: bwp.c:271
int check_trigger(object *op, object *cause)
Definition: button.c:523
object * generate_treasure(treasurelist *t, int difficulty)
Generate a treasure from a list generating a single item.
Definition: treasure.c:518
This is a game-map.
Definition: map.h:325
const New_Face * face
Face with colors.
Definition: object.h:332
static char * do_template(const char *template, const char **vars, const char **values)
Processes a template.
Definition: bwp.c:185
void push(String_Array *array, const char *string)
Add a string to a String_Array struct.
Definition: bwp.c:310
EXTERN archetype * first_archetype
First archetype.
Definition: global.h:122
char * monster_page_head
Definition: bwp.c:45
const char * name
More definite name, like "generate_kobold".
Definition: object.h:466
void init_artifacts(void)
Builds up the lists of artifacts from the file in the libdir.
Definition: artifact.c:513
#define HAS_RANDOM_ITEMS(op)
This return TRUE if object has still randomitems which could be expanded.
Definition: define.h:183
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
Definition: object.c:1654