From: davidf@linuxfan.com Subject: bridger To: pingus-devel@lists.deus.net Date: Thu, 16 Dec 1999 01:18:31 +0100 Resent-From: pingus-devel@lists.deus.net Reply-To: pingus-devel@lists.deus.net Hi, my name is David Flores and I has been looking to contribute to develope pingus. But first I had had to learn C++ and study pingus source code :-). So this if my first change to the source code. Now a bridge is not like a wall, a pingu can walk under a bridge. To test it I had had to modify the "bridging" algorithm of brigger.cc because a bridger pingu can't build a bridger in a flat land. I don't know exactly what's the problem but my code is an horrendous solution. Ok, this are the diffs: Index: pingus/src/ColMap.cc =================================================================== RCS file: /home/mbn/public_cvsroot/pingus/src/ColMap.cc,v retrieving revision 1.17 diff -r1.17 ColMap.cc 260a261,263 > case surface_data::BRIDGE: > colmap[i] = BRIDGE; > break; Index: pingus/src/Pingu.cc =================================================================== RCS file: /home/mbn/public_cvsroot/pingus/src/Pingu.cc,v retrieving revision 1.36 diff -r1.36 Pingu.cc 401,411c401,420 < } else if (rel_getpixel(1,2) == ColMap::NOTHING) { < x_pos += direction; < y_pos -= 2; < } else { // WALL < for (unsigned int i=0; i < persist.size(); ++i) { < if (persist[i]->get_type() & (ActionType)WALL) { < if (action && persist[i]->name() == action->name()) { < cout << "Not using action, we have allready" << endl; < } else { < cout << "We are infront of a wall, setting persistant action" << endl; < set_paction(persist[i]->create()); --- > } else > if (rel_getpixel(1,2) == ColMap::NOTHING) { > x_pos += direction; > y_pos -= 2; > } else > if (rel_getpixel(1,2) == ColMap::BRIDGE) { > x_pos += direction; > y_pos -=3; > } > else { // WALL > for (unsigned int i=0; i < persist.size(); ++i) { > if (persist[i]->get_type() & (ActionType)WALL) { > if (action && persist[i]->name() == action->name()) { > cout << "Not using action, we have allready" << endl; > } else { > cout << "We are infront of a wall, setting persistant action" << endl; > set_paction(persist[i]->create()); > } > return; > } 413,417c422,423 < return; < } < } < direction.change(); < } --- > direction.change(); > } 571a578 > Index: pingus/src/actions/bridger.cc =================================================================== RCS file: /home/mbn/public_cvsroot/pingus/src/actions/bridger.cc,v retrieving revision 1.15 diff -r1.15 bridger.cc 46a47 > 50,51c51,52 < // if (rel_getpixel(1,0) == ColMap::NOTHING) { < pingu->colmap->put(brick, pingu->x_pos, pingu->y_pos); --- > if( (rel_getpixel(2,-2) == ColMap::NOTHING) || (bricks > 35) ){ > pingu->colmap->put(brick, pingu->x_pos, pingu->y_pos, surface_data::BRIDGE); 54c55 < pingu->x_pos += pingu->direction; --- > pingu->x_pos += 2*pingu->direction; 60c61,73 < /* } else { --- > } > else { > if(rel_getpixel(1,-1) == ColMap::NOTHING){ > pingu->colmap->put(brick,pingu->x_pos,pingu->y_pos, surface_data::BRIDGE); > pingu->map->put(brick->get_provider(), pingu->x_pos, pingu->y_pos); > > pingu->x_pos += pingu->direction; > > if(step++) { > pingu->y_pos -= 1; > step = 0; > } > } 62,63c75,77 < }*/ < } else { --- > } > } > else { Testing this code I find a big problem. I left two pingus walking between a blocker and a wall, when others pingus are died then the computer memory is progressiv exhausted by the pingus process. When there is no more room then xwindow and pingus crashed. -- Bye David Flores