Update of /cvsroot/timewarp/source/melee In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4583/source/melee Modified Files: mcbodies.cpp mcbodies.h mframe.cpp mframe.h mhelpers.cpp mmain.cpp mmain.h mship.cpp mshpdata.cpp msprite.cpp Log Message: debugging Index: mshpdata.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mshpdata.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mshpdata.cpp 23 Aug 2005 22:19:09 -0000 1.12 --- mshpdata.cpp 28 Aug 2005 20:31:32 -0000 1.13 *************** *** 29,32 **** --- 29,36 ---- void test_pointers() { + #ifdef _DEBUG + if (!physics) + return; + // also check the target list int i; *************** *** 48,51 **** --- 52,56 ---- } } + #endif } *************** *** 423,427 **** } // end of the test. ! */ --- 428,432 ---- } // end of the test. ! //*/ Index: mcbodies.h =================================================================== RCS file: /cvsroot/timewarp/source/melee/mcbodies.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mcbodies.h 11 Jul 2005 00:25:13 -0000 1.11 --- mcbodies.h 28 Aug 2005 20:31:32 -0000 1.12 *************** *** 59,63 **** static SpaceSprite *starpics; Stars2(); ! ~Stars2(); int num_layers; StarLayer *layer; --- 59,63 ---- static SpaceSprite *starpics; Stars2(); ! virtual ~Stars2(); int num_layers; StarLayer *layer; *************** *** 70,74 **** public: Stars(); ! ~Stars(); SpaceSprite **pic; double width; --- 70,74 ---- public: Stars(); ! virtual ~Stars(); SpaceSprite **pic; double width; Index: mmain.h =================================================================== RCS file: /cvsroot/timewarp/source/melee/mmain.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** mmain.h 11 Jul 2005 00:25:28 -0000 1.17 --- mmain.h 28 Aug 2005 20:31:32 -0000 1.18 *************** *** 45,49 **** }; ! ~NormalGame(); virtual void calculate(); --- 45,49 ---- }; ! virtual ~NormalGame(); virtual void calculate(); Index: mmain.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mmain.cpp,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** mmain.cpp 21 Aug 2005 12:43:31 -0000 1.44 --- mmain.cpp 28 Aug 2005 20:31:32 -0000 1.45 *************** *** 1068,1072 **** add ( new WedgeIndicator ( s, 30, p->color ) ); ShipPanel *panel = new ShipPanel(s); ! panel->window->init(window); panel->window->locate( 0, 0.9, --- 1068,1072 ---- add ( new WedgeIndicator ( s, 30, p->color ) ); ShipPanel *panel = new ShipPanel(s); ! panel->window->init(window); //xxx this causes the flicker in the screen. panel->window->locate( 0, 0.9, Index: mcbodies.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mcbodies.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** mcbodies.cpp 26 Aug 2005 21:54:30 -0000 1.18 --- mcbodies.cpp 28 Aug 2005 20:31:32 -0000 1.19 *************** *** 125,129 **** SpaceObject *o; Query a; ! a.begin(this, OBJECT_LAYERS, gravity_range); for (;a.currento;a.next()) { o = a.currento; --- 125,129 ---- SpaceObject *o; Query a; ! a.begin(this, OBJECT_LAYERS, gravity_range, QUERY_OBJECT); for (;a.currento;a.next()) { o = a.currento; Index: msprite.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/msprite.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** msprite.cpp 23 Aug 2005 22:19:09 -0000 1.25 --- msprite.cpp 28 Aug 2005 20:31:32 -0000 1.26 *************** *** 309,312 **** --- 309,317 ---- BITMAP *src = get_bitmap(i, 0);//b[0][i]; + if ( level < 0 || level > highest_mip || level > MAX_MIP_LEVELS) + { + tw_error("Illegal mipmap used..."); + } + sbitmap[level][i] = create_bitmap_ex(bpp, lw, lh); *************** *** 341,350 **** lw = iround(w * pow(0.5, level)); lh = iround(h * pow(0.5, level)); - if ((lw < 8) || (lh < 8)) break; - this->highest_mip = level; - this->sbitmap[level] = new BITMAP*[count]; ! this->highest_mip = level; ! this->sbitmap[level] = new BITMAP*[count]; for (i = 0; i < count; i += 1) --- 346,360 ---- lw = iround(w * pow(0.5, level)); lh = iround(h * pow(0.5, level)); ! if ((lw < 8) || (lh < 8)) ! break; ! ! if (sbitmap[level]) ! { ! tw_error("new mipmap level: already defined!"); ! } ! ! highest_mip = level; ! sbitmap[level] = new BITMAP*[count]; for (i = 0; i < count; i += 1) *************** *** 447,451 **** highest_mip = 0; for (i = 1; i < MAX_MIP_LEVELS; i += 1) { ! sbitmap[i] = NULL; } --- 457,461 ---- highest_mip = 0; for (i = 1; i < MAX_MIP_LEVELS; i += 1) { ! sbitmap[i] = 0; } *************** *** 752,757 **** if (smask) delete[] smask; ! ! smask = NULL; for (l = 0; l <= highest_mip; l += 1) --- 762,766 ---- if (smask) delete[] smask; ! smask = 0; for (l = 0; l <= highest_mip; l += 1) *************** *** 765,775 **** destroy_bitmap(sbitmap[l][i]); } delete[] sbitmap[l]; ! sbitmap[l] = NULL; } } delete[] attributes; ! attributes = NULL; return; } --- 774,785 ---- destroy_bitmap(sbitmap[l][i]); } + delete[] sbitmap[l]; ! sbitmap[l] = 0; } } delete[] attributes; ! attributes = 0; return; } Index: mship.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mship.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** mship.cpp 26 Aug 2005 21:59:16 -0000 1.42 --- mship.cpp 28 Aug 2005 20:31:32 -0000 1.43 *************** *** 332,337 **** id = SPACE_SHIP; ! type = NULL; ! code = NULL; // modified otherwise the kat poly crashes --- 332,338 ---- id = SPACE_SHIP; ! type = 0; ! code = 0; ! // data is initialized in SpaceLocation constructor // modified otherwise the kat poly crashes *************** *** 366,370 **** control(NULL) {STACKTRACE - shipData->lock(); attributes |= ATTRIB_SHIP; layer = LAYER_SHIPS; --- 367,370 ---- *************** *** 379,383 **** --- 379,394 ---- captain_name[0] = '\0'; ship = this; + + if (data) + { + tw_error("ship with data out of nowhere? Shouldn't be possible."); + } data = shipData; + if (!data) + { + tw_error("A ship without data."); + } + data->lock(); + this->ally_flag = ally_flag; *************** *** 472,475 **** --- 483,487 ---- delete spritePanel; + spritePanel = 0; //f (override_control) Index: mframe.h =================================================================== RCS file: /cvsroot/timewarp/source/melee/mframe.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** mframe.h 26 Aug 2005 21:54:30 -0000 1.27 --- mframe.h 28 Aug 2005 20:31:32 -0000 1.28 *************** *** 20,24 **** class Presence; ! void delete_location(void *tmp); void check_physics_correctness(); void check_physics_correctness_item(int i); --- 20,24 ---- class Presence; ! void delete_location(SpaceLocation *tmp); void check_physics_correctness(); void check_physics_correctness_item(int i); *************** *** 315,318 **** --- 315,319 ---- virtual void change_vel(Vector2 dvel); + virtual void set_vel(Vector2 newvel); virtual void scale_vel(double scale); virtual void change_pos(Vector2 dpos); *************** *** 427,430 **** --- 428,439 ---- }; + enum query_type { QUERY_LOC = 1, QUERY_OBJECT, QUERY_LINE }; + + /** searching a grid. + You can specify layers which space locations and objects are in. Those are not a guarantee for + the correct type. + If you make use of currento, then specify QUERY_OBJECT + If you make use of currentl, then specify QUERY_LINE + */ struct Query { private: *************** *** 436,439 **** --- 445,449 ---- Vector2 target_pos; double range_sqr; + query_type qtype; void next_quadrant (); public: *************** *** 443,456 **** SpaceLocation *current; }; ! void begin (SpaceLocation *target, int layers, double range); ! void begin (SpaceLocation *target, Vector2 center, int layers, double range); void next (); void end(); private: ! bool current_invalid() { ! if (!(bit(current->layer) & layers) || (current == target) || !current->exists()) return true; ! if (magnitude_sqr(min_delta(target_pos, current->normal_pos())) > range_sqr) return true; ! return false; ! } }; --- 453,462 ---- SpaceLocation *current; }; ! void begin (SpaceLocation *target, int layers, double range, query_type qqtype = QUERY_LOC); ! void begin (SpaceLocation *target, Vector2 center, int layers, double range, query_type qqtype = QUERY_LOC); void next (); void end(); private: ! bool current_invalid(); }; Index: mframe.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mframe.cpp,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** mframe.cpp 26 Aug 2005 21:54:30 -0000 1.42 --- mframe.cpp 28 Aug 2005 20:31:32 -0000 1.43 *************** *** 60,63 **** --- 60,64 ---- void check_physics_correctness_item(int i) { + #ifdef _DEBUG if (physics) { *************** *** 72,84 **** } ! if (fabs(l->pos.x) > 1E6 || fabs(l->pos.y) > 1E6 || fabs(l->vel.x) > 1E6 || fabs(l->vel.x) > 1E6) { tw_error("error in item [%i] [%s]", i, l->get_identity()); } } } void check_physics_correctness() { int i; for ( i = 0; i < physics->num_items; ++i ) --- 73,87 ---- } ! if (fabs(l->pos.x) > 1E6 || fabs(l->pos.y) > 1E6 || fabs(l->vel.x) > 1E6 || fabs(l->vel.y) > 1E6) { tw_error("error in item [%i] [%s]", i, l->get_identity()); } } + #endif } void check_physics_correctness() { + #ifdef _DEBUG int i; for ( i = 0; i < physics->num_items; ++i ) *************** *** 86,93 **** --- 89,98 ---- check_physics_correctness_item(i); } + #endif } void check_physics_presence(Presence *p) { + #ifdef _DEBUG if (!physics) return; *************** *** 108,118 **** } } } ! void Query::begin (SpaceLocation *qtarget, int qlayers, double qrange) {STACKTRACE bool old_physics_allows = physics_allowed; physics_allowed = true; if (qrange < 0) {tw_error("Query::begin - negative range");} --- 113,160 ---- } } + #endif } ! bool Query::current_invalid() ! { ! if (!(bit(current->layer) & layers) || (current == target) || !current->exists()) ! return true; ! ! if (magnitude_sqr(min_delta(target_pos, current->normal_pos())) > range_sqr) ! return true; ! ! switch (qtype) ! { ! case QUERY_LOC: ! { ! if (!current->isLocation()) ! return true; ! break; ! } ! case QUERY_OBJECT: ! { ! if (!current->isObject()) ! return true; ! break; ! } ! case QUERY_LINE: ! { ! tw_error("query_line, is this ever used?"); ! if (!current->isLine()) ! return true; ! break; ! } ! } ! ! return false; ! } ! ! ! void Query::begin (SpaceLocation *qtarget, int qlayers, double qrange, query_type qqtype) {STACKTRACE bool old_physics_allows = physics_allowed; physics_allowed = true; + qtype = qqtype; if (qrange < 0) {tw_error("Query::begin - negative range");} *************** *** 153,157 **** } ! void Query::begin (SpaceLocation *qtarget, Vector2 center, int qlayers, double qrange) { STACKTRACE; --- 195,199 ---- } ! void Query::begin (SpaceLocation *qtarget, Vector2 center, int qlayers, double qrange, query_type qqtype) { STACKTRACE; *************** *** 159,162 **** --- 201,205 ---- bool old_physics_allows = physics_allowed; physics_allowed = true; + qtype = qqtype; layers = qlayers; *************** *** 418,422 **** // the "left-over" data that still remain in memory (for a while). attributes &= ~ATTRIB_INGAME; ! check_physics_presence(this); #endif } --- 461,465 ---- // the "left-over" data that still remain in memory (for a while). attributes &= ~ATTRIB_INGAME; ! //check_physics_presence(this); #endif } *************** *** 467,471 **** angle(langle), damage_factor(0), ! collide_flag_anyone(ALL_LAYERS), collide_flag_sameteam(0), collide_flag_sameship(0) --- 510,515 ---- angle(langle), damage_factor(0), ! //collide_flag_anyone(ALL_LAYERS), ! collide_flag_anyone(0), // a location shouldn't collide... collide_flag_sameteam(0), collide_flag_sameship(0) *************** *** 483,487 **** data = creator->data; ! if (data) data->lock(); target = creator->target; --- 527,532 ---- data = creator->data; ! if (data) ! data->lock(); target = creator->target; *************** *** 493,500 **** else { ally_flag = 0; ! ship = NULL; ! parent = NULL; ! data = NULL; ! target = NULL; } } --- 538,545 ---- else { ally_flag = 0; ! ship = 0; ! parent = 0; ! data = 0; ! target = 0; } } *************** *** 504,508 **** { STACKTRACE ! if (data) data->unlock(); #ifdef _DEBUG --- 549,554 ---- { STACKTRACE ! if (data) ! data->unlock(); #ifdef _DEBUG *************** *** 609,615 **** --- 655,678 ---- } + inline void check_vector_sanity(Vector2 &v) + { + #ifdef _DEBUG + if (fabs(v.x) > 1E6 || fabs(v.y) > 1E6 ) + { + tw_error("invalid velocity change"); + } + #endif + } + void SpaceLocation::change_vel(Vector2 dvel) { vel += dvel; + check_vector_sanity(vel); + } + + void SpaceLocation::set_vel(Vector2 newvel) + { + vel = newvel; + check_vector_sanity(vel); } *************** *** 617,620 **** --- 680,684 ---- { vel *= scale; + check_vector_sanity(vel); } *************** *** 624,627 **** --- 688,692 ---- { pos = normalize(pos + dpos); + check_vector_sanity(pos); } *************** *** 631,634 **** --- 696,700 ---- { pos *= scale; + check_vector_sanity(pos); } *************** *** 658,666 **** ! int SpaceLocation::canCollide(SpaceLocation *other) { ! if (!detectable()) return 0; ! if (sameShip(other)) return ((1 << other->layer) & collide_flag_sameship); ! else if (sameTeam(other)) return ((1 << other->layer) & collide_flag_sameteam); ! return ((1 << other->layer) & collide_flag_anyone); } --- 724,774 ---- ! int SpaceLocation::canCollide(SpaceLocation *other) ! { ! if (!other) ! return 0; ! ! int result; ! ! result = 1; ! ! // if it's not part of the physics ! if (!detectable()) ! result = 0; ! ! // if you are only allowed to collide with other ships ! //if ( collide_flag_sameship == 0) ! if ( (collide_flag_sameship & bit(other->layer) ) == 0) ! { ! if (sameShip(other)) ! result = 0; ! } ! ! // if you should not collide with objects from the same ship ! //if (collide_flag_sameship == 0) ! if ( (collide_flag_sameship & bit(other->layer) ) == 0) ! { ! // but they share the same parent ! if ( other->parent == parent ) ! result = 0; // then set to zero, because they're brothers ! } ! ! // if you are only allowed to collide with ships from other teams ! //if (collide_flag_sameteam == 0) ! if ( (collide_flag_sameteam & bit(other->layer) ) == 0) ! { ! // but the other happens to be in the same team ! if (sameTeam(other)) ! result = 0; // then set it to 0 ! } ! ! // if you are not allowed to collide with *anyone* ... ! //if (collide_flag_anyone == 0) ! if ( (collide_flag_anyone & bit(other->layer) ) == 0) ! { ! result = 0; ! } ! ! return result; } *************** *** 748,764 **** nvm = magnitude_sqr(nv); if ((nvm <= max_speed * max_speed) || (nvm <= ovm)) { ! vel = nv; } else { if (ovm <= max_speed * max_speed) ovm = max_speed; else ovm = sqrt(ovm); ! vel = nv * ovm / (ovm + velocity); ! } ! #ifdef _DEBUG ! if (fabs(vel.x) > 1E6 || fabs(vel.y) > 1E6) ! { ! tw_error("accelerate: velocity overflow..."); } - #endif return; } --- 856,866 ---- nvm = magnitude_sqr(nv); if ((nvm <= max_speed * max_speed) || (nvm <= ovm)) { ! set_vel( nv ); } else { if (ovm <= max_speed * max_speed) ovm = max_speed; else ovm = sqrt(ovm); ! set_vel( nv * ovm / (ovm + velocity) ); } return; } *************** *** 773,777 **** //if new velocity is slow, handle normally //if new velocity is fast, but we're decelerating, still handle normally ! vel = nv; } else { --- 875,879 ---- //if new velocity is slow, handle normally //if new velocity is fast, but we're decelerating, still handle normally ! set_vel( nv ); } else { *************** *** 780,791 **** //otherwise, slow down closer to the maximum speed //but only when turning, particularly turning fast ! vel = nv * ovm / (ovm + magnitude(delta_v)); ! } ! #ifdef _DEBUG ! if (fabs(vel.x) > 1E6 || fabs(vel.y) > 1E6) ! { ! tw_error("accelerate: velocity overflow..."); } - #endif return; } --- 882,887 ---- //otherwise, slow down closer to the maximum speed //but only when turning, particularly turning fast ! set_vel ( nv * ovm / (ovm + magnitude(delta_v)) ); } return; } *************** *** 812,816 **** } ! void SpaceLocation::calculate() {STACKTRACE if (target && !target->exists()) { target_died(); --- 908,915 ---- } ! void SpaceLocation::calculate() ! { ! STACKTRACE; ! if (target && !target->exists()) { target_died(); *************** *** 874,878 **** {STACKTRACE attributes |= ATTRIB_OBJECT; ! if (game && game->friendly_fire) collide_flag_sameteam = ALL_LAYERS; collide_flag_sameship = 0; collide_flag_anyone = ALL_LAYERS; --- 973,978 ---- {STACKTRACE attributes |= ATTRIB_OBJECT; ! //if (game && game->friendly_fire) ! collide_flag_sameteam = ALL_LAYERS; collide_flag_sameship = 0; collide_flag_anyone = ALL_LAYERS; *************** *** 900,904 **** if (this == other) {tw_error("SpaceObject::collide - self!");} ! if((!canCollide(other)) || (!other->canCollide(this))) return; if (!exists() || !other->exists()) return; --- 1000,1010 ---- if (this == other) {tw_error("SpaceObject::collide - self!");} ! ! // BOTH need to be able to collide to each other ! // in order to get a well-defined result. If one of them can't collide, and its code ! // assumes that it will not collide, a forced collision can introduce an error. ! if( (this->canCollide(other) & other->canCollide(this)) == 0 ) ! return; ! if (!exists() || !other->exists()) return; *************** *** 976,985 **** } - #ifdef _DEBUG - if (fabs(vel.x) > 1E6 || fabs(vel.y) > 1E6 || fabs(other->vel.x) > 1E6 || fabs(other->vel.y) > 1E6 ) - { - tw_error("velocity error involving objects [%s] and [%s]", get_identity(), other->get_identity()); - } - #endif return; --- 1082,1085 ---- *************** *** 988,1013 **** double SpaceObject::collide_ray(Vector2 lp1, Vector2 lp2, double llength) {STACKTRACE - int collide_x = (int)(lp2.x); - int collide_y = (int)(lp2.y); - Vector2 d; double old_length = llength; double magn = 0; if (sprite->collide_ray( ! (int)(lp1.x), (int)(lp1.y), &collide_x, &collide_y, ! (int)(lp1.x - min_delta(lp1.x, pos.x, map_size.x)), ! (int)(lp1.y - min_delta(lp1.y, pos.y, map_size.y)), ! sprite_index)) { ! d = lp2 - Vector2(collide_x, collide_y); ! magn = magnitude(d); ! llength = llength - magn; } ! if (llength < -2) { ! tw_error("negative length!"); ! } else { llength = 0; } --- 1088,1127 ---- double SpaceObject::collide_ray(Vector2 lp1, Vector2 lp2, double llength) {STACKTRACE double old_length = llength; double magn = 0; + // line origin (position) + int x1 = (int)(lp1.x); + int y1 = (int)(lp1.y); + + // line end (position) ; this is subject to change + int collide_x = (int)(lp2.x); + int collide_y = (int)(lp2.y); + + // object position (unwrapped w.r.t. the line origin). + int sx = (int)(lp1.x + min_delta(pos.x, lp1.x, map_size.x)); + int sy = (int)(lp1.y + min_delta(pos.y, lp1.y, map_size.y)); + if (sprite->collide_ray( ! x1, y1, ! &collide_x, &collide_y, ! sx, sy, ! sprite_index)) ! { ! //Vector2 d; ! //d = lp2 - Vector2(collide_x, collide_y); ! //magn = magnitude(d); ! //llength = llength - magn; ! llength = magnitude( Vector2(collide_x, collide_y) - lp1 ); } ! if (llength < 0) { ! if (llength < -2) ! { ! tw_error("negative length!"); ! } llength = 0; } *************** *** 1066,1072 **** layer = LAYER_LINES; set_depth(DEPTH_LINES); ! collide_flag_anyone &= OBJECT_LAYERS; ! collide_flag_sameteam &= OBJECT_LAYERS; ! collide_flag_sameship &= OBJECT_LAYERS; if (length < 0) --- 1180,1186 ---- layer = LAYER_LINES; set_depth(DEPTH_LINES); ! collide_flag_anyone = OBJECT_LAYERS; ! collide_flag_sameteam = OBJECT_LAYERS; ! collide_flag_sameship = 0; if (length < 0) *************** *** 1351,1355 **** extern void test_pointers(); ! void delete_location(void *tmp) { if (!physics) --- 1465,1469 ---- extern void test_pointers(); ! void delete_location(SpaceLocation *tmp) { if (!physics) *************** *** 1367,1376 **** // otherwise, it's ok to remove it. delete tmp; } ! static const int max_physics_pointer_test = 1024; ! static int num_physics_pointer_test = 0; ! static SpaceLocation *physics_pointer_test[max_physics_pointer_test]; void Physics::calculate() {_STACKTRACE("Physics::calculate()") --- 1481,1491 ---- // otherwise, it's ok to remove it. + const char *name = 0; + if (tmp->data) + name = tmp->data->file; delete tmp; } ! void Physics::calculate() {_STACKTRACE("Physics::calculate()") *************** *** 1388,1393 **** debug_value = num_items + num_presences; ! test_pointers(); ! check_physics_correctness(); checksync(); --- 1503,1508 ---- debug_value = num_items + num_presences; ! //test_pointers(); ! //check_physics_correctness(); checksync(); *************** *** 1409,1414 **** checksync(); ! test_pointers(); ! check_physics_correctness(); {_STACKTRACE("Physics::calculate() - presence calculation") --- 1524,1529 ---- checksync(); ! //test_pointers(); ! //check_physics_correctness(); {_STACKTRACE("Physics::calculate() - presence calculation") *************** *** 1420,1425 **** } } ! test_pointers(); ! check_physics_correctness(); //call objects calculate functions --- 1535,1540 ---- } } ! //test_pointers(); ! //check_physics_correctness(); //call objects calculate functions *************** *** 1433,1441 **** tw_error("Pointer error, overwritten data ??"); } - //test_pointers(); item[i]->calculate(); ! //test_pointers(); // try to intercept a couple of errors that are possible here ... --- 1548,1557 ---- tw_error("Pointer error, overwritten data ??"); } item[i]->calculate(); ! //xxx costly check... ! //check_physics_correctness(); ! // try to intercept a couple of errors that are possible here ... *************** *** 1458,1462 **** } } ! test_pointers(); check_physics_correctness(); --- 1574,1578 ---- } } ! //test_pointers(); check_physics_correctness(); *************** *** 1484,1489 **** collide(); } ! test_pointers(); ! check_physics_correctness(); checksync(); --- 1600,1605 ---- collide(); } ! //test_pointers(); ! //check_physics_correctness(); checksync(); *************** *** 1510,1527 **** } } ! test_pointers(); ! check_physics_correctness(); checksync(); - // checking for mem-overwrite - for(i = 0; i < num_physics_pointer_test; i ++) - { - if (physics_pointer_test[i] != item[i]) - { - tw_error("Physics memory array has been changed !!"); - } - } - // end of test //remove objects that have been dead long enough --- 1626,1634 ---- } } ! //test_pointers(); ! //check_physics_correctness(); checksync(); //remove objects that have been dead long enough *************** *** 1538,1545 **** i -= 1; const char *name = tmp->get_identity(); ! if (strcmp(name, "AsteroidCenter") == 0) ! { ! int k = 0; ! } delete_location(tmp); //xxx despite that TEST, it's still going wrong here !! So, something gets deleted outside of this physics, after being added to the physics... nasty!. --- 1645,1649 ---- i -= 1; const char *name = tmp->get_identity(); ! //delete tmp; delete_location(tmp); //xxx despite that TEST, it's still going wrong here !! So, something gets deleted outside of this physics, after being added to the physics... nasty!. *************** *** 1548,1557 **** } - // copying info for mem-overwrite test - num_physics_pointer_test = max_physics_pointer_test; - if (num_physics_pointer_test > num_items) - num_physics_pointer_test = num_items; - memcpy(physics_pointer_test, item, num_physics_pointer_test * sizeof(SpaceLocation*)); - // end of copy for(i = 0; i < num_items; i ++) --- 1652,1655 ---- *************** *** 1609,1615 **** game_frame_rate = 0.1 * game_frame_rate + 0.9 * (get_time() - game_animation_time); game_animation_time = get_time(); ! message.print(1, 15, "frame rate = %i ms", int(game_frame_rate)); ! check_physics_correctness(); #endif --- 1707,1713 ---- game_frame_rate = 0.1 * game_frame_rate + 0.9 * (get_time() - game_animation_time); game_animation_time = get_time(); ! // message.print(1, 15, "frame rate = %i ms", int(game_frame_rate)); ! //check_physics_correctness(); #endif *************** *** 1694,1701 **** ! check_physics_correctness(); } ! check_physics_correctness(); return; --- 1792,1799 ---- ! //check_physics_correctness(); } ! //check_physics_correctness(); return; *************** *** 1745,1750 **** SpaceObject *o = 0; Query q; ! for (q.begin(l, normalize(l->pos+l->edge()/2, map_size), OBJECT_LAYERS, 96 + l->get_length()/2); q.current && l->exists(); q.next()) { double d; --- 1843,1853 ---- SpaceObject *o = 0; + Vector2 lineorigin = l->pos; + Vector2 offset = l->edge()/2; + Vector2 center = normalize(lineorigin + offset, map_size); + Query q; ! for (q.begin(l, center, OBJECT_LAYERS, 96 + distance/2, QUERY_OBJECT); ! q.currento && l->exists(); q.next()) { double d; *************** *** 1786,1791 **** tmp[l].y = p.y; if (tmp[l].y < 0) tmp[l].y += size.y; ! //xxx goes wrong in case of Androsynth Guardian (=o) ; m=0x00003c. ! tmp[l].pmask = o->get_sprite()->get_pmask(o->get_sprite_index()); #ifdef _DEBUG --- 1889,1896 ---- tmp[l].y = p.y; if (tmp[l].y < 0) tmp[l].y += size.y; ! ! SpaceSprite *spr = o->get_sprite(); ! int index = o->get_sprite_index(); ! tmp[l].pmask = spr->get_pmask(index); #ifdef _DEBUG *************** *** 1804,1809 **** delete[] tmp; // return; ! for (i = 0; i < nc; i += 1) { col[i*2]->collide(col[i*2+1]); }//*/ Query q; --- 1909,1928 ---- delete[] tmp; // return; ! ! for (i = 0; i < nc; i += 1) ! { col[i*2]->collide(col[i*2+1]); + + #ifdef _DEBUG + SpaceObject *c1 = col[i*2]; + SpaceObject *c2 = col[i*2+1]; + if (fabs(c1->vel.x) > 1E6 || fabs(c1->vel.y) > 1E6 || fabs(c2->vel.x) > 1E6 || fabs(c2->vel.y) > 1E6 ) + { + int a1 = c1->canCollide(c2); + int a2 = c2->canCollide(c1); + bool b = ((c1->canCollide(c2) & c2->canCollide(c1)) == 0 ); + tw_error("velocity error in collision involving objects [%s] and [%s]", c1->get_identity(), c2->get_identity()); + } + #endif }//*/ Query q; Index: mhelpers.cpp =================================================================== RCS file: /cvsroot/timewarp/source/melee/mhelpers.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** mhelpers.cpp 16 Aug 2005 18:17:29 -0000 1.10 --- mhelpers.cpp 28 Aug 2005 20:31:32 -0000 1.11 *************** *** 573,576 **** --- 573,577 ---- if (parent && (parent != this)) parent->add_callback ( this ); update_pos(); + event(VideoEvent::RESIZE); event(VideoEvent::REDRAW); |