From: <js...@us...> - 2004-08-28 05:36:14
|
Update of /cvsroot/exult/exult In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5975 Modified Files: ChangeLog actorio.cc gamemap.cc gamemap.h Log Message: Save/restore ireg. objs. with high shape nums. Index: ChangeLog =================================================================== RCS file: /cvsroot/exult/exult/ChangeLog,v retrieving revision 1.1895 retrieving revision 1.1896 diff -u -d -r1.1895 -r1.1896 --- ChangeLog 16 Aug 2004 22:25:35 -0000 1.1895 +++ ChangeLog 28 Aug 2004 05:36:02 -0000 1.1896 @@ -1,3 +1,7 @@ +2004-08-27 <je...@mi...> + + * gamemap.cc, objs/*: Save/restore ireg. objs. with shape # >= 1024. + 2004-08-14 Dominik Reichardt <do...@us...> * docs/xml/docs.xml,faq.xml: updated documentation and FAQ * docs/xml/html.xsl: got rid of another pointer to our ML Index: actorio.cc =================================================================== RCS file: /cvsroot/exult/exult/actorio.cc,v retrieving revision 1.139 retrieving revision 1.140 diff -u -d -r1.139 -r1.140 --- actorio.cc 4 Jul 2004 08:24:25 -0000 1.139 +++ actorio.cc 28 Aug 2004 05:36:03 -0000 1.140 @@ -461,8 +461,13 @@ int old_shape = get_shapenum(); // Backup shape because we might change it set_shape( get_shape_real() ); // Change the shape out non polymorph one - - write_common_ireg(buf4); + // ++++++In future, got to handle shapenum > 1023. + int shapenum = get_shapenum(), framenum = get_framenum(); + buf4[0] = ((get_cx()%16) << 4) | get_tx(); + buf4[1] = ((get_cy()%16) << 4) | get_ty(); + buf4[2] = shapenum&0xff; + buf4[3] = ((shapenum>>8)&3) | (framenum<<2); + nfile->write(reinterpret_cast<char*>(buf4), sizeof(buf4)); set_shape( old_shape ); // Revert the shape to what it was Index: gamemap.cc =================================================================== RCS file: /cvsroot/exult/exult/gamemap.cc,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- gamemap.cc 11 Jul 2004 08:51:11 -0000 1.55 +++ gamemap.cc 28 Aug 2004 05:36:03 -0000 1.56 @@ -876,7 +876,7 @@ static Egg_object *Create_egg ( - unsigned char *entry, // 1-byte ireg entry. + unsigned char *entry, // 12-byte ireg entry. bool animated ) { @@ -923,6 +923,7 @@ unsigned long flags // Usecode item flags. ) { + unsigned char entbuf[20]; int entlen; // Gets entry length. sint8 index_id = -1; Game_object *last_obj = 0; // Last one read in this call. @@ -930,6 +931,7 @@ // Go through entries. while (((entlen = ireg->read1(), !ireg->eof()))) { + int extended = 0; // 1 for 2-byte shape #'s. // Skip 0's & ends of containers. @@ -951,18 +953,24 @@ Read_special_ireg(ireg, last_obj); continue; } + else if (entlen == IREG_EXTENDED) + { + extended = 1; + entlen = ireg->read1(); + } // Get copy of flags. unsigned long oflags = flags & ~(1<<Obj_flags::is_temporary); - if (entlen != 6 && entlen != 10 && entlen != 12 && - entlen != 18) + int testlen = entlen - extended; + if (testlen != 6 && testlen != 10 && testlen != 12 && + testlen != 18) { long pos = ireg->getPos(); - cout << "Unknown entlen " << entlen << " at pos. " << + cout << "Unknown entlen " << testlen << " at pos. " << pos << endl; ireg->seek(pos + entlen); continue; // Only know these two types. } - unsigned char entry[18];// Get entry. + unsigned char *entry = &entbuf[0]; // Get entry. ireg->read(reinterpret_cast<char*>(entry), entlen); int cx = entry[0] >> 4; // Get chunk indices within schunk. int cy = entry[1] >> 4; @@ -978,10 +986,18 @@ tilex = entry[0] & 0xf; tiley = entry[1] & 0xf; } - // Get shape #, frame #. - int shnum = entry[2]+256*(entry[3]&3); - int frnum = entry[3] >> 2; - + int shnum, frnum; // Get shape #, frame #. + if (extended) + { + shnum = entry[2]+256*entry[3]; + frnum = entry[4]; + ++entry; // So the rest is in the right place. + } + else + { + shnum = entry[2]+256*(entry[3]&3); + frnum = entry[3] >> 2; + } Shape_info& info = ShapeID::get_info(shnum); unsigned int lift, quality, type; Ireg_game_object *obj; @@ -989,7 +1005,7 @@ // An "egg"? // Has flag byte(s) - if (entlen == 10) + if (testlen == 10) { // Temporary if (entry[6] & 1) oflags |= 1<<Obj_flags::is_temporary; @@ -998,12 +1014,13 @@ if (info.get_shape_class() == Shape_info::hatchable) { bool anim = info.is_animated() || info.has_sfx(); + assert(!extended); // Not handled yet. Egg_object *egg = Create_egg(entry, anim); get_chunk(scx + cx, scy + cy)->add_egg(egg); last_obj = egg; continue; } - else if (entlen == 6 || entlen == 10) // Simple entry? + else if (testlen == 6 || testlen == 10) // Simple entry? { type = 0; lift = entry[4] >> 4; @@ -1027,7 +1044,7 @@ quality = 0; } } - else if (entlen == 12) // Container? + else if (testlen == 12) // Container? { type = entry[4] + 256*entry[5]; lift = entry[9] >> 4; @@ -1061,16 +1078,6 @@ obj = new Jawbone_object(shnum, frnum, tilex, tiley, lift, entry[10]); } - else if (Game::get_game_type() == SERPENT_ISLE && - shnum == 400 && frnum == 8 && quality == 1) - // Gwenno. Ugly hack to fix bug without having to start - // a new game. Remove someday... (added 20010820) - { - Dead_body *b = new Dead_body(400, 8, - tilex, tiley, lift, 149); - obj = b; - gwin->set_body(149, b); - } else if (quality == 1 && (entry[8] >= 0x80 || Game::get_game_type() == SERPENT_ISLE)) Index: gamemap.h =================================================================== RCS file: /cvsroot/exult/exult/gamemap.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- gamemap.h 26 Jun 2004 23:00:34 -0000 1.18 +++ gamemap.h 28 Aug 2004 05:36:03 -0000 1.19 @@ -42,6 +42,8 @@ class Shapes_vga_file; class DataSource; +#define IREG_EXTENDED 254 // For shape #'s > 1023. + /* * The game map: */ |