int load_s_marker (s_marker * m, PACKFILE * f) { pack_fread (m->name, sizeof (m->name), f); m->x = pack_igetw (f); m->y = pack_igetw (f); return 0; }
int load_s_entity(s_entity *s, PACKFILE *f) { s->chrx = pack_getc(f); pack_getc(f); /* alignment */ s->x = pack_igetw(f); s->y = pack_igetw(f); s->tilex = pack_igetw(f); s->tiley = pack_igetw(f); s->eid = pack_getc(f); s->active = pack_getc(f); s->facing = pack_getc(f); s->moving = pack_getc(f); s->movcnt = pack_getc(f); s->framectr = pack_getc(f); s->movemode = pack_getc(f); s->obsmode = pack_getc(f); s->delay = pack_getc(f); s->delayctr = pack_getc(f); s->speed = pack_getc(f); s->scount = pack_getc(f); s->cmd = pack_getc(f); s->sidx = pack_getc(f); s->extra = pack_getc(f); s->chasing = pack_getc(f); pack_igetw(f); /* alignment */ s->cmdnum = pack_igetl(f); s->atype = pack_getc(f); s->snapback = pack_getc(f); s->facehero = pack_getc(f); s->transl = pack_getc(f); pack_fread(s->script, sizeof(s->script), f); return 0; }
int load_s_bound (s_bound * b, PACKFILE * f) { b->x1 = pack_igetw (f); b->y1 = pack_igetw (f); b->x2 = pack_igetw (f); b->y2 = pack_igetw (f); b->btile = pack_igetw (f); return 0; }
int load_s_tileset (s_tileset * s, PACKFILE * f) { int i; pack_fread (s->icon_set, sizeof (s->icon_set), f); for (i = 0; i < MAX_ANIM; ++i) { s->tanim[i].start = pack_igetw (f); s->tanim[i].end = pack_igetw (f); s->tanim[i].delay = pack_igetw (f); } return 0; }
int load_s_map (s_map * sm, PACKFILE * f) { int i; sm->map_no = pack_getc (f); sm->zero_zone = pack_getc (f); sm->map_mode = pack_getc (f); sm->can_save = pack_getc (f); sm->tileset = pack_getc (f); sm->use_sstone = pack_getc (f); sm->can_warp = pack_getc (f); sm->extra_byte = pack_getc (f); sm->xsize = pack_igetl (f); sm->ysize = pack_igetl (f); sm->pmult = pack_igetl (f); sm->pdiv = pack_igetl (f); sm->stx = pack_igetl (f); sm->sty = pack_igetl (f); sm->warpx = pack_igetl (f); sm->warpy = pack_igetl (f); sm->revision = pack_igetl (f); sm->extra_sdword2 = pack_igetl (f); pack_fread (sm->song_file, sizeof (sm->song_file), f); pack_fread (sm->map_desc, sizeof (sm->map_desc), f); if (sm->revision >= 1) { /* Markers stuff */ sm->num_markers = pack_igetw (f); sm->markers = (s_marker *) realloc (sm->markers, sm->num_markers * sizeof (s_marker)); for (i = 0; i < sm->num_markers; ++i) { load_s_marker (&sm->markers[i], f); } if (sm->revision >= 2) { /* Bounding boxes stuff */ sm->num_bound_boxes = pack_igetw (f); sm->bound_box = (s_bound *) realloc (sm->bound_box, sm->num_bound_boxes * sizeof (s_bound)); for (i = 0; i < sm->num_bound_boxes; ++i) { load_s_bound (&sm->bound_box[i], f); } } else { sm->num_bound_boxes = 0; } } else { sm->num_markers = 0; sm->num_bound_boxes = 0; } return 0; }
void load_entity(PACKFILE *file,ENTITY *data) { data->x = pack_igetl(file); data->y = pack_igetl(file); data->speed = pack_igetl(file); data->type = pack_getc(file); data->data1 = pack_igetw(file); data->data2 = pack_igetw(file); data->data3 = pack_igetw(file); data->data4 = pack_igetw(file); data->health = pack_igetw(file); data->maxcooldown = pack_igetl(file); data->cooldown = data->maxcooldown; }
void TiledMapLayer::loadFrom(PACKFILE *file, TileRepository *tileRepository) { ASSERT(file); // Load the map header int w = pack_igetw(file); int h = pack_igetw(file); resizeTo(w, h); // Load the tile data for (int y = 0; y < mapHeight; y++) for (int x = 0; x < mapWidth; x++) getTile(Point(x,y))->loadFrom(file, tileRepository); }
void Tile::loadFrom(PACKFILE *file, TileRepository *tileRepository) { // Load tile name from file and look it up in the tile repository char name[32]; pack_fgets(name, 32, file); setType(tileRepository->getTileType(name)); obstacle = pack_igetw(file); }
/*! \brief Load all markers in from packfile * * Loads individual \sa s_marker objects from the specified PACKFILE. * * \param[in,out] marray - Current array of markers to be reallocated * \param[in] pf - PACKFILE from whence data are pulled * \return Non-0 on error, 0 on success */ size_t load_markers (s_marker_array *marray, PACKFILE *pf) { s_marker *mmarker = NULL; size_t i; assert (marray && "marray == NULL"); assert (pf && "pf == NULL"); if (!marray || !pf) { printf ("NULL passed into load_markers()\n"); return 1; } marray->size = pack_igetw (pf); if (pack_feof (pf)) { assert (0 && "pack_igetw() for marray->size received EOF signal."); printf ("Expected value for number of markers. Instead, received EOF.\n"); return 2; } else if (marray->size == 0) { marray->array = NULL; return 0; // Success: okay to have 0 markers in a map } marray->array = (s_marker *) realloc (marray->array, marray->size * sizeof (s_marker)); for (i = 0; i < marray->size; ++i) { mmarker = &marray->array[i]; pack_fread (mmarker->name, sizeof (mmarker->name), pf); mmarker->x = pack_igetw (pf); mmarker->y = pack_igetw (pf); if (pack_feof (pf)) { assert (0 && "pack_igetw() for marker->[xy] received EOF signal."); printf ("Encountered EOF during marker read.\n"); return 3; } } return 0; // Success }
//second parameter is ignored void* load_level(PACKFILE *file,int size) { int i; LEVEL *data; data = calloc(1,sizeof(LEVEL)); //read small stuff and malloc things data->sizey = pack_igetw(file); data->sizex = pack_igetw(file); data->length = data->sizex * data->sizey; printf("sizex=%d, sizey=%d, length=%d", data->sizex, data->sizey, data->length); data->map = calloc(data->length,1); data->bgtype = pack_getc(file); if (data->bgtype == 1) for(i = 0;i < 600;i++) data->lines[i] = makecol24(pack_getc(file),pack_getc(file),pack_getc(file)); data->entitycnt = pack_igetw(file); data->entities = calloc(data->entitycnt,sizeof(ENTITY)); //do serios file magic pack_fread(data->map,data->length,file); for (i = 0;i < data->entitycnt;i++) { load_entity(file,&data->entities[i]); } return data; }
int readblock(PACKFILE *f) { long size; int c = pack_igetw(f); if (c == -1) return 0; size = c; sourcebuf = (dword*)malloc(size+4); if (!sourcebuf) return 0; c = pack_fread(sourcebuf, size, f); if (c < 1) { free(sourcebuf); sourcebuf = NULL; return 0; } sourcepos = sourcebuf; rembits = 32; return 1; }
/* loads a MSK file (Animator and Animator Pro format) */ Mask *load_msk_file(const char *filename) { #if (MAKE_VERSION(4, 2, 1) >= MAKE_VERSION(ALLEGRO_VERSION, \ ALLEGRO_SUB_VERSION, \ ALLEGRO_WIP_VERSION)) int orig_size = file_size(filename); #else int orig_size = file_size_ex(filename); #endif int i, c, u, v, byte, magic, size; Mask *mask = NULL; PACKFILE *f; f = pack_fopen(filename, F_READ); if (!f) return NULL; size = pack_igetl(f); magic = pack_igetw(f); /* Animator Pro MSK format */ if ((size == orig_size) && (magic == 0x9500)) { Image *image; int x, y; pack_fclose(f); /* just load an Animator Pro PIC file */ image = load_pic_file(filename, &x, &y, NULL); if ((!image) || (image->imgtype != IMAGE_BITMAP)) { if (image) image_free(image); } else { mask = mask_new(); mask->x = x; mask->y = y; mask->w = image->w; mask->h = image->h; mask->bitmap = image; } } /* Animator MSK format */ else if (orig_size == 8000) { mask = mask_new(); mask_replace(mask, 0, 0, 320, 200); u = v = 0; for (i=0; i<8000; i++) { byte = pack_getc (f); for (c=0; c<8; c++) { mask->bitmap->putpixel(u, v, byte & (1<<(7-c))); u++; if (u == 320) { u = 0; v++; } } } pack_fclose(f); } else { pack_fclose(f); } return mask; }
static GIF_ANIMATION * load_object (PACKFILE * file, long size) { int version; BITMAP *bmp = NULL; int i, j; GIF_ANIMATION *gif = calloc (1, sizeof *gif); GIF_FRAME frame; int have_global_palette = 0; (void) size; gif->frames_count = 0; /* is it really a GIF? */ if (pack_getc (file) != 'G') goto error; if (pack_getc (file) != 'I') goto error; if (pack_getc (file) != 'F') goto error; if (pack_getc (file) != '8') goto error; /* '7' or '9', for 87a or 89a. */ version = pack_getc (file); if (version != '7' && version != '9') goto error; if (pack_getc (file) != 'a') goto error; gif->width = pack_igetw (file); gif->height = pack_igetw (file); i = pack_getc (file); /* Global color table? */ if (i & 128) gif->palette.colors_count = 1 << ((i & 7) + 1); else gif->palette.colors_count = 0; /* Background color is only valid with a global palette. */ gif->background_index = pack_getc (file); /* Skip aspect ratio. */ pack_fseek (file, 1); if (gif->palette.colors_count) { read_palette (file, &gif->palette); have_global_palette = 1; } memset(&frame, 0, sizeof frame); /* For first frame. */ frame.transparent_index = -1; do { i = pack_getc (file); switch (i) { case 0x2c: /* Image Descriptor */ { int w, h; int interlaced = 0; frame.xoff = pack_igetw (file); frame.yoff = pack_igetw (file); w = pack_igetw (file); h = pack_igetw (file); bmp = create_bitmap_ex (8, w, h); if (!bmp) goto error; i = pack_getc (file); /* Local palette. */ if (i & 128) { frame.palette.colors_count = 1 << ((i & 7) + 1); read_palette (file, &frame.palette); } else { frame.palette.colors_count = 0; } if (i & 64) interlaced = 1; if (LZW_decode (file, bmp)) goto error; if (interlaced) deinterlace (bmp); frame.bitmap_8_bit = bmp; bmp = NULL; gif->frames_count++; gif->frames = realloc (gif->frames, gif->frames_count * sizeof *gif->frames); gif->frames[gif->frames_count - 1] = frame; memset(&frame, 0, sizeof frame); /* For next frame. */ frame.transparent_index = -1; break; } case 0x21: /* Extension Introducer. */ j = pack_getc (file); /* Extension Type. */ i = pack_getc (file); /* Size. */ if (j == 0xf9) /* Graphic Control Extension. */ { /* size must be 4 */ if (i != 4) goto error; i = pack_getc (file); frame.disposal_method = (i >> 2) & 7; frame.duration = pack_igetw (file); if (i & 1) /* Transparency? */ { frame.transparent_index = pack_getc (file); } else { pack_fseek (file, 1); frame.transparent_index = -1; } i = pack_getc (file); /* Size. */ } /* Application Extension. */ else if (j == 0xff) { if (i == 11) { char name[12]; pack_fread (name, 11, file); i = pack_getc (file); /* Size. */ name[11] = '\0'; if (!strcmp (name, "NETSCAPE2.0")) { if (i == 3) { j = pack_getc (file); gif->loop = pack_igetw (file); if (j != 1) gif->loop = 0; i = pack_getc (file); /* Size. */ } } } } /* Possibly more blocks until terminator block (0). */ while (i) { pack_fseek (file, i); i = pack_getc (file); } break; case 0x3b: /* GIF Trailer. */ pack_fclose (file); return gif; } } while (TRUE); error: if (file) pack_fclose (file); if (gif) algif_destroy_raw_animation (gif); if (bmp) destroy_bitmap (bmp); return NULL; }
/*! \brief Load mini stats * * This loads the mini stats for each saved game. * These mini stats are just for displaying info about the save game on the * save/load game screen. */ void load_sgstats (void) { PACKFILE *ldat; int a, b, c; unsigned char vc; s_player tpm; for (a = 0; a < NUMSG; a++) { sprintf (strbuf, "sg%d.sav", a); ldat = pack_fopen (kqres (SAVE_DIR, strbuf), F_READ_PACKED); if (!ldat) { snc[a] = 0; sgp[a] = 0; shr[a] = 0; smin[a] = 0; for (b = 0; b < PSIZE; b++) { sid[a][b] = 0; shp[a][b] = 0; smp[a][b] = 0; } } else { vc = pack_getc (ldat); if (vc == 92) { sgp[a] = pack_igetl (ldat); shr[a] = pack_igetw (ldat); smin[a] = pack_igetw (ldat); snc[a] = pack_igetw (ldat); for (b = 0; b < snc[a]; b++) { sid[a][b] = pack_igetw (ldat); // sid[a][b] = 0; // Temp: Debugging / Testing } pack_igetw (ldat); // Number of characters in game. Assume MAXCHRS for (b = 0; b < MAXCHRS; b++) { load_s_player (&tpm, ldat); for (c = 0; c < snc[a]; c++) { if (b == sid[a][c]) { slv[a][c] = tpm.lvl; shp[a][c] = tpm.hp * 100 / tpm.mhp; if (tpm.mmp > 0) smp[a][c] = tpm.mp * 100 / tpm.mmp; else smp[a][c] = 0; } } } } else if (vc == 91) { snc[a] = pack_igetl (ldat); sgp[a] = pack_igetl (ldat); shr[a] = pack_igetl (ldat); smin[a] = pack_igetl (ldat); for (b = 0; b < PSIZE; b++) { sid[a][b] = pack_igetl (ldat); } for (b = 0; b < MAXCHRS; b++) { load_s_player (&tpm, ldat); for (c = 0; c < PSIZE; c++) { if (b == sid[a][c]) { slv[a][c] = tpm.lvl; shp[a][c] = tpm.hp * 100 / tpm.mhp; if (tpm.mmp > 0) smp[a][c] = tpm.mp * 100 / tpm.mmp; else smp[a][c] = 0; } } } } else snc[a] = -1; pack_fclose (ldat); } } }
/*! \brief Load game * * Loads game using KQ save game format 92 (Beta) * Author: Winter Knight * \returns 1 if load succeeded, 0 otherwise */ static int load_game_92 (PACKFILE *sdat) { size_t a, b, c, d; /* Already got kq_version */ gp = pack_igetl (sdat); khr = pack_igetw (sdat); kmin = pack_igetw (sdat); /* Load number of, and which characters in party */ numchrs = pack_igetw (sdat); if (numchrs > PSIZE) { message (_("Error. numchrs in saved game > PSIZE"), 255, 0, 0, 0); return 0; } for (a = 0; a < numchrs; a++) { pidx[a] = pack_igetw (sdat); g_ent[a].eid = pidx[a]; g_ent[a].active = 1; } /* Zero set empty party character(s), if any */ for (; a < PSIZE; a++) { pidx[a] = 0; g_ent[a].active = 0; } /* Load number of, and data on all characters in game */ pack_igetw (sdat); /* max number of characters is fixed in KQ */ for (a = 0; a < MAXCHRS; a++) { load_s_player (&party[a], sdat); } /* Load map name and location */ a = pack_igetw (sdat); if (a > sizeof (curmap)) { message (_("Error. number of chars in saved game > sizeof(curmap)"), 255, 0, 0, 0); return 0; } pack_fread (curmap, a, sdat); curmap[a] = 0; // pack_fread does not append a NULL to the end of a string. g_ent[0].tilex = pack_igetw (sdat); g_ent[0].tiley = pack_igetw (sdat); /* Load Quest Info */ b = pack_igetw (sdat); if (b > sizeof (progress)) { message (_("Error. number of progress indicators > sizeof(progress)"), 255, 0, 0, 0); return 0; } for (a = 0; a < b; a++) progress[a] = pack_getc (sdat); /* zero-set blank Quest Info */ for (; a < sizeof (progress); a++) progress[a] = 0; /* Load treasure info */ b = pack_igetw (sdat); if (b > sizeof (treasure)) { message (_("Error. number of treasure indicators > sizeof(treasure)"), 255, 0, 0, 0); return 0; } for (a = 0; a < b; a++) treasure[a] = pack_getc (sdat); /* zero-set blank treasure info */ for (; a < sizeof (treasure); a++) treasure[a] = 0; /* Load spell info */ b = pack_igetw (sdat); if (b > sizeof (save_spells)) { message (_("Error. number of non-combat spell indicators > sizeof(save_spells)"), 255, 0, 0, 0); return 0; } for (a = 0; a < b; a++) save_spells[a] = pack_getc (sdat); /* zero-set empty spell slots */ for (; a < sizeof (save_spells); a++) save_spells[a] = 0; /* Load player inventory */ b = pack_igetw (sdat); if (b > MAX_INV) { message (_("Error. number of inventory items > MAX_INV"), 255, 0, 0, 0); return 0; } for (a = 0; a < b; a++) { g_inv[a][0] = pack_igetw (sdat); g_inv[a][1] = pack_igetw (sdat); } /* zero-set empty inventory slots */ for (; a < MAX_INV; a++) { g_inv[a][0] = 0; g_inv[a][1] = 0; } /* Load special items info */ b = pack_igetw (sdat); if (b > MAX_SPECIAL_ITEMS) { message (_("Error. number of special items > MAX_SPECIAL_ITEMS"), 255, 0, 0, 0); return 0; } for (a = 0; a < b; a++) player_special_items[a] = pack_getc (sdat); /* index */ /* zero-set empty special item slots */ for (; a < MAX_SPECIAL_ITEMS; a++) player_special_items[a] = 0; /* Load shop info (last visit time and number of items) */ b = pack_igetw (sdat); if (b > NUMSHOPS) { message (_("Error. number of shops saved > NUMSHOPS"), 255, 0, 0, 0); return 0; } /* b = number of shop * a = current shop index * c = number of items in current shop * d = current item index */ for (a = 0; a < b; a++) { shop_time[a] = pack_igetw (sdat); c = pack_igetw (sdat); for (d = 0; d < c; d++) shops[a].items_current[d] = pack_igetw (sdat); for (; d < SHOPITEMS; d++) shops[a].items_current[d] = shops[a].items_max[d]; } /* Replenish all shops that were not saved (haven't been visited yet) */ for (a = b; a < NUMSHOPS; a++) { for (d = 0; d < SHOPITEMS; d++) shops[a].items_current[d] = shops[a].items_max[d]; } return 1; }
int load_game_91 (PACKFILE *sdat) { unsigned int a, b; numchrs = pack_igetl (sdat); gp = pack_igetl (sdat); khr = pack_igetl (sdat); kmin = pack_igetl (sdat); for (a = 0; a < PSIZE; a++) { pidx[a] = pack_igetl (sdat); g_ent[a].active = 0; if (a < numchrs) { g_ent[a].eid = pidx[a]; g_ent[a].active = 1; } } for (a = 0; a < MAXCHRS; a++) { load_s_player (&party[a], sdat); } pack_fread (curmap, 16, sdat); for (a = 0; a < SIZE_PROGRESS; a++) { /* 1750 */ progress[a] = pack_getc (sdat); } for (a = 0; a < NUMSHOPS; a++) { /* 50 */ shop_time[a] = pack_getc (sdat); } for (a = 0; a < SIZE_SAVE_RESERVE1; a++) { /* 150 */ pack_getc (sdat); } for (a = 0; a < SIZE_SAVE_SPELL; a++) { /* 50 */ save_spells[a] = pack_getc (sdat); } for (a = 0; a < sizeof (treasure); a++) { treasure[a] = pack_getc (sdat); } for (a = 0; a < NUMSHOPS; a++) { for (b = 0; b < SHOPITEMS; b++) { shops[a].items_current[b] = pack_igetw (sdat); } } for (a = 0; a < MAX_INV; a++) { g_inv[a][0] = pack_igetw (sdat); g_inv[a][1] = pack_igetw (sdat); } /* Bunch of 0s for alignment */ pack_igetl (sdat); pack_igetl (sdat); pack_getc (sdat); pack_getc (sdat); pack_getc (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); pack_igetl (sdat); /* End worthless */ g_ent[0].tilex = pack_igetw (sdat); g_ent[0].tiley = pack_igetw (sdat); /* Fill special_items array with info from saved game */ #define P_UCOIN 36 #define P_CANCELROD 37 #define P_GOBLINITEM 17 #define P_UNDEADJEWEL 35 #define P_WSTONES 24 #define P_BSTONES 25 #define P_EMBERSKEY 46 #define P_BRONZEKEY 70 #define P_DENORIAN 55 #define P_OPALHELMET 43 #define P_OPALSHIELD 50 #define P_IRONKEY 66 #define P_OPALBAND 69 #define P_OPALARMOUR 90 #define P_CAVEKEY 71 #define P_TALK_TSORIN 108 #define P_TALKOLDMAN 110 #define SI_UCOIN 0 #define SI_CANCELROD 1 #define SI_JADEPENDANT 2 #define SI_UNDEADJEWEL 3 #define SI_WHITESTONE 4 #define SI_BLACKSTONE 5 #define SI_EMBERSKEY 6 #define SI_BRONZEKEY 7 #define SI_DENORIANSTATUE 8 #define SI_OPALHELMET 9 #define SI_OPALSHIELD 10 #define SI_IRONKEY 11 #define SI_OPALBAND 12 #define SI_OPALARMOUR 13 #define SI_CAVEKEY 14 #define SI_NOTE_TSORIN 15 #define SI_NOTE_DERIG 16 #define SI_RUSTYKEY 17 if (progress[P_UCOIN] == 2) player_special_items[SI_UCOIN] = 1; if (progress[P_CANCELROD] == 1) player_special_items[SI_CANCELROD] = 1; if (progress[P_GOBLINITEM] == 1) player_special_items[SI_JADEPENDANT] = 1; if (progress[P_UNDEADJEWEL] == 1) player_special_items[SI_UNDEADJEWEL] = 1; if (progress[P_WSTONES] > 0) player_special_items[SI_WHITESTONE] = progress[P_WSTONES]; if (progress[P_BSTONES] > 0) player_special_items[SI_BLACKSTONE] = progress[P_BSTONES]; if (progress[P_EMBERSKEY] == 2) player_special_items[SI_EMBERSKEY] = 1; if (progress[P_BRONZEKEY] == 1) player_special_items[SI_BRONZEKEY] = 1; if (progress[P_DENORIAN] == 3 || progress[P_DENORIAN] == 4) player_special_items[SI_DENORIANSTATUE] = 1; if (progress[P_OPALHELMET] == 1) player_special_items[SI_OPALHELMET] = 1; if (progress[P_OPALSHIELD] == 1) player_special_items[SI_OPALSHIELD] = 1; if (progress[P_OPALBAND] == 1) player_special_items[SI_OPALBAND] = 1; if (progress[P_OPALARMOUR] == 1) player_special_items[SI_OPALARMOUR] = 1; if (progress[P_CAVEKEY] == 1) player_special_items[SI_CAVEKEY] = 1; if (progress[P_IRONKEY] == 1) player_special_items[SI_IRONKEY] = 1; if (progress[P_TALK_TSORIN] == 1) player_special_items[SI_NOTE_TSORIN] = 1; if (progress[P_TALK_TSORIN] == 2) player_special_items[SI_NOTE_DERIG] = 1; if (progress[P_TALKOLDMAN] > 2) player_special_items[SI_RUSTYKEY] = 1; #if 0 a = 0; if (progress[P_UCOIN] == 2) { strcpy (special_items[a].name, _("Unadium coin")); strcpy (special_items[a].description, _("Use to reach ruins")); special_items[a].quantity = 1; special_items[a].icon = 50; a++; } if (progress[P_CANCELROD] == 1) { strcpy (special_items[a].name, _("Cancellation Rod")); strcpy (special_items[a].description, _("Nullify magic")); special_items[a].quantity = 1; special_items[a].icon = 51; a++; } if (progress[P_GOBLINITEM] == 1) { strcpy (special_items[a].name, _("Jade Pendant")); strcpy (special_items[a].description, _("Magical goblin gem")); special_items[a].quantity = 1; special_items[a].icon = 52; a++; } if (progress[P_UNDEADJEWEL] == 1) { strcpy (special_items[a].name, _("Goblin Jewel")); strcpy (special_items[a].description, _("Precious artifact")); special_items[a].quantity = 1; special_items[a].icon = 53; a++; } if (progress[P_WSTONES] > 0) { strcpy (special_items[a].name, _("White Stone")); strcpy (special_items[a].description, _("Smooth white rock")); special_items[a].quantity = progress[P_WSTONES]; special_items[a].icon = 54; a++; } if (progress[P_BSTONES] > 0) { strcpy (special_items[a].name, _("Black Stone")); strcpy (special_items[a].description, _("Smooth black rock")); special_items[a].quantity = progress[P_BSTONES]; special_items[a].icon = 55; a++; } if (progress[P_EMBERSKEY] == 2) { strcpy (special_items[a].name, _("Ember's Key")); strcpy (special_items[a].description, _("Unlock stuff")); special_items[a].quantity = 1; special_items[a].icon = 56; a++; } if (progress[P_BRONZEKEY] == 1) { strcpy (special_items[a].name, _("Bronze Key")); strcpy (special_items[a].description, _("Unlock stuff")); special_items[a].quantity = 1; special_items[a].icon = 57; a++; } if (progress[P_DENORIAN] == 3 || progress[P_DENORIAN] == 4) { strcpy (special_items[a].name, _("Denorian Statue")); strcpy (special_items[a].description, _("Broken in half")); special_items[a].quantity = 1; special_items[a].icon = 58; a++; } if (progress[P_OPALHELMET] == 1) { strcpy (special_items[a].name, _("Opal Helmet")); strcpy (special_items[a].description, _("Piece of opal set")); special_items[a].quantity = 1; special_items[a].icon = 59; a++; } if (progress[P_OPALSHIELD] == 1) { strcpy (special_items[a].name, _("Opal Shield")); strcpy (special_items[a].description, _("Piece of opal set")); special_items[a].quantity = 1; special_items[a].icon = 60; a++; } if (progress[P_IRONKEY] == 1) { strcpy (special_items[a].name, _("Iron Key")); strcpy (special_items[a].description, _("Unlock stuff")); special_items[a].quantity = 1; special_items[a].icon = 61; a++; } if (progress[P_OPALBAND] == 1) { strcpy (special_items[a].name, _("Opal Band")); strcpy (special_items[a].description, _("Piece of opal set")); special_items[a].quantity = 1; special_items[a].icon = 62; a++; } if (progress[P_OPALARMOUR] == 1) { strcpy (special_items[a].name, _("Opal Armour")); strcpy (special_items[a].description, _("Piece of opal set")); special_items[a].quantity = 1; special_items[a].icon = 14; a++; } if (progress[P_CAVEKEY] == 1) { strcpy (special_items[a].name, _("Cave Key")); strcpy (special_items[a].description, _("Unlock stuff")); special_items[a].quantity = 1; special_items[a].icon = 63; a++; } if (progress[P_TALK_TSORIN] == 1) { strcpy (special_items[a].name, _("Tsorin's Note")); strcpy (special_items[a].description, _("Sealed envelope")); special_items[a].quantity = 1; special_items[a].icon = 18; a++; } if (progress[P_TALK_TSORIN] == 2) { strcpy (special_items[a].name, _("Derig's Note")); strcpy (special_items[a].description, _("Encrypted message")); special_items[a].quantity = 1; special_items[a].icon = 18; a++; } if (progress[P_TALKOLDMAN] > 2) { strcpy (special_items[a].name, _("Rusty Key")); strcpy (special_items[a].description, _("Unlock grotto ruins")); special_items[a].quantity = 1; special_items[a].icon = 64; a++; } #endif #undef P_UCOIN #undef P_CANCELROD #undef P_GOBLINITEM #undef P_UNDEADJEWEL #undef P_WSTONES #undef P_BSTONES #undef P_EMBERSKEY #undef P_BRONZEKEY #undef P_DENORIAN #undef P_OPALHELMET #undef P_OPALSHIELD #undef P_IRONKEY #undef P_OPALBAND #undef P_OPALARMOUR #undef P_CAVEKEY #undef P_TALK_TSORIN #undef P_TALKOLDMAN return 1; }
void TiledMap::loadFrom(PACKFILE *file, TileRepository *tileRepository) { ASSERT(file); // Remove the objects from the map list<Object*>::iterator i; while (!objects.empty()) { i = objects.begin(); delete (*i); objects.erase(i); } // Load the map header int version = pack_igetw(file); int layers = pack_igetw(file); // Load the tile data //allegro_message("Loading %d layers from map version %d", layers, version); for (int i = 0; i < layers; i++) { mapLayers[i]->loadFrom(file, tileRepository); } // Load object data if (version == 3) { int nrObjects = pack_igetw(file); for (int i = 0; i < nrObjects; i++) { int x = pack_igetw(file); //int(TILES_W * (*i)->x), file); int y = pack_igetw(file); //pack_iputw(int(TILES_H * (*i)->y), file); char *className = new char[64]; int objectInstance = 0; pack_fgets(className, 64, file); // Spawn the object // Assumes Lua environment is set up and such of course lua_pushstring(L, className); lua_gettable(L, LUA_GLOBALSINDEX); if (!lua_isnil(L, -1)) { lua_call(L, putLuaArguments(L, "m", this), 1); if (lua_istable(L, -1)) { objectInstance = lua_ref(L, -1); } else { console.log(CON_QUIT, CON_ALWAYS, "Error while instaniating object \"%s\"", className); } } else { console.log(CON_QUIT, CON_ALWAYS, "Error: could not find object class \"%s\"", className); } lua_getref(L, objectInstance); lua_pushstring(L, "_pointer"); lua_gettable(L, -2); Object* obj = (Object*)lua_touserdata(L, -1); obj->x = (double(x) / TILES_W); obj->y = (double(y) / TILES_H); obj->className = className; // Assign class name (maybe not the best place for this) lua_pop(L, 1); } } mapWidth = mapLayers[0]->getWidth(); mapHeight = mapLayers[0]->getHeight(); }