00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #define LO_NEWFILE 2
00030
00031
00032
00033 #include <time.h>
00034 #include <stdio.h>
00035 #include <global.h>
00036 #include <maze_gen.h>
00037 #include <room_gen.h>
00038 #include <random_map.h>
00039 #include <rproto.h>
00040
00041 int main(int argc, char *argv[]) {
00042 char InFileName[1024], OutFileName[1024];
00043 mapstruct *newMap;
00044 RMParms rp;
00045 FILE *fp;
00046
00047 if (argc < 3) {
00048 printf("\nUsage: %s inputfile outputfile\n", argv[0]);
00049 exit(0);
00050 }
00051
00052 strcpy(InFileName, argv[1]);
00053 strcpy(OutFileName, argv[2]);
00054
00055 init_globals();
00056 init_library();
00057 init_archetypes();
00058 init_artifacts();
00059 init_formulae();
00060 init_readable();
00061
00062 init_gods();
00063 memset(&rp, 0, sizeof(RMParms));
00064 rp.Xsize = -1;
00065 rp.Ysize = -1;
00066 if ((fp = fopen(InFileName, "r")) == NULL) {
00067 fprintf(stderr, "\nError: can not open %s\n", InFileName);
00068 exit(1);
00069 }
00070 load_parameters(fp, LO_NEWFILE, &rp);
00071 fclose(fp);
00072 newMap = generate_random_map(OutFileName, &rp, NULL);
00073 save_map(newMap, SAVE_MODE_INPLACE);
00074 exit(0);
00075 }
00076
00077 void set_map_timeout(mapstruct *oldmap) {
00078
00079 }
00080
00081 #include <global.h>
00082
00083
00084
00085 int auto_apply(object *op) {
00086 object *tmp = NULL;
00087 int i;
00088
00089 switch (op->type) {
00090 case SHOP_FLOOR:
00091 if (!HAS_RANDOM_ITEMS(op))
00092 return 0;
00093 do {
00094 i = 10;
00095 while ((tmp = generate_treasure(op->randomitems, op->stats.exp ? op->stats.exp : 5)) == NULL && --i)
00096 ;
00097 if (tmp == NULL)
00098 return 0;
00099 if (QUERY_FLAG(tmp, FLAG_CURSED) || QUERY_FLAG(tmp, FLAG_DAMNED)) {
00100 free_object(tmp);
00101 tmp = NULL;
00102 }
00103 } while (!tmp);
00104
00105 tmp->x = op->x,
00106 tmp->y = op->y;
00107 SET_FLAG(tmp, FLAG_UNPAID);
00108 insert_ob_in_map(tmp, op->map, NULL, 0);
00109 CLEAR_FLAG(op, FLAG_AUTO_APPLY);
00110 identify(tmp);
00111 break;
00112
00113 case TREASURE:
00114 if (HAS_RANDOM_ITEMS(op))
00115 while ((op->stats.hp--) > 0)
00116 create_treasure(op->randomitems, op, GT_ENVIRONMENT, op->stats.exp ? op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0);
00117 remove_ob(op);
00118 free_object(op);
00119 break;
00120 }
00121
00122 return tmp ? 1 : 0;
00123 }
00124
00125
00126
00127
00128
00129
00130 void fix_auto_apply(mapstruct *m) {
00131 object *tmp, *above = NULL;
00132 int x, y;
00133
00134 for (x = 0; x < MAP_WIDTH(m); x++)
00135 for (y = 0; y < MAP_HEIGHT(m); y++)
00136 for (tmp = GET_MAP_OB(m, x, y); tmp != NULL; tmp = above) {
00137 above = tmp->above;
00138
00139 if (QUERY_FLAG(tmp, FLAG_AUTO_APPLY))
00140 auto_apply(tmp);
00141 else if (tmp->type == TREASURE) {
00142 if (HAS_RANDOM_ITEMS(tmp))
00143 while ((tmp->stats.hp--) > 0)
00144 create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
00145 }
00146 if (tmp && tmp->arch
00147 && tmp->type != PLAYER
00148 && tmp->type != TREASURE
00149 && tmp->randomitems) {
00150 if (tmp->type == CONTAINER) {
00151 if (HAS_RANDOM_ITEMS(tmp))
00152 while ((tmp->stats.hp--) > 0)
00153 create_treasure(tmp->randomitems, tmp, 0, m->difficulty, 0);
00154 } else if (HAS_RANDOM_ITEMS(tmp))
00155 create_treasure(tmp->randomitems, tmp, GT_APPLY, m->difficulty, 0);
00156 }
00157 }
00158 for (x = 0; x < MAP_WIDTH(m); x++)
00159 for (y = 0; y < MAP_HEIGHT(m); y++)
00160 for (tmp = GET_MAP_OB(m, x, y); tmp != NULL; tmp = tmp->above)
00161 if (tmp->above
00162 && (tmp->type == TRIGGER_BUTTON || tmp->type == TRIGGER_PEDESTAL))
00163 check_trigger(tmp, tmp->above);
00164 }
00165
00171 void draw_ext_info(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *txt, const char *txt2) {
00172 fprintf(logfile, "%s\n", txt);
00173 }
00174
00175 void draw_ext_info_format(int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *new_format, const char *old_format, ...) {
00176 va_list ap;
00177
00178 va_start(ap, old_format);
00179 vfprintf(logfile, old_format, ap);
00180 va_end(ap);
00181 }
00182
00183
00184 void ext_info_map(int color, const mapstruct *map, uint8 type, uint8 subtype, const char *str1, const char *str2) {
00185 fprintf(logfile, "ext_info_map: %s\n", str2);
00186 }
00187
00188 void move_firewall(object *ob) {
00189 }
00190
00191 void emergency_save(int x) {
00192 }
00193
00194 void clean_tmp_files(void) {
00195 }
00196
00197 void esrv_send_item(object *ob, object *obx) {
00198 }
00199
00200 void esrv_update_item(int flags, object *pl, object *op) {
00201 }
00202
00203 void dragon_ability_gain(object *ob, int x, int y) {
00204 }
00205
00206 void set_darkness_map(mapstruct *m) {
00207 }
00208
00209 object *find_skill_by_number(object *who, int skillno) {
00210 return NULL;
00211 }
00212
00213 void esrv_del_item(player *pl, int tag) {
00214 }
00215
00216 void esrv_update_spells(player *pl) {
00217 }
00218
00219 void monster_check_apply(object *ob, object *obt) {
00220 }
00221
00222 void trap_adjust(object *ob, int x) {
00223 }
00224
00225 int execute_event(object *op, int eventcode, object *activator, object *third, const char *message, int fix) {
00226 return 0;
00227 }
00228
00229 int execute_global_event(int eventcode, ...) {
00230 return 0;
00231 }