[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[bos-dev] StartGathering () in engine/action/action_resource.cpp
- To: bos-dev@xxxxxxxx
- Subject: [bos-dev] StartGathering () in engine/action/action_resource.cpp
- From: Ivan Shmakov <oneingray@xxxxxxxxx>
- Date: Mon, 22 Jun 2009 23:57:12 +0700
- Cc: Ivan Shmakov <oneingray@xxxxxxxxx>
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: bos-dev-outgoing@xxxxxxxx
- Delivered-to: bos-dev@xxxxxxxx
- Delivery-date: Mon, 22 Jun 2009 12:57:22 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:subject:to:cc:date :message-id:user-agent:mime-version:content-type; bh=aLBi36e79zZ8aMfEXuinaAAdFnq4ghkAqOsueomZTgM=; b=o/pEG1H1WvhrvWNx2igE8QVAL7cDpx1B3K2r5pk2/cV8EekcknXTRd6gdzeXoQnAvw tClS2G/8vUUP2RPQSu7FRR5Tc5AOcc3Rfa+AQVeHYW2D2DAzeKJfTI0DWNNR2MCjihAn 0au5ahG2PwilXnssaKkVpbXMtqoPQLfHbvUN8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:subject:to:cc:date:message-id:user-agent:mime-version :content-type; b=utE0XGBrhEsd/Kz+Dls5rCobzZ88mzlI6casHtNr8g0gyAkGllImsCM/o5dAATz2gh RucjfSX/2th3yO8dzUmrfBw26oISuTMBuUXDfY+oSBuK+Jbn44NtHCVL42LVTP+5uVOL Z568e5gqRhMYUviI32XiabSsQLnNMYGH7A3F8=
- Reply-to: bos-dev@xxxxxxxx
- Sender: owner-bos-dev@xxxxxxxx
- User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)
I wonder, why the following fragment is implemented as part of
the engine?
Apparently, the code assigns goals to harvesting units that
already has finished their harvest, but, alas, does it a bit
unintelligently, by sending, e. g., units formely doing magma
extraction to cutting down the forests and vice versa. Also,
IIUC, there'd be no signal (either to the messages buffer or to
the Lua code) from the unit that has just finished the harvest
and is unable to find more.
Perhaps, having such a piece of code out of the engine itself
would allow for more smart implementations? What would be the
prerequisites for such a refactoring?
BTW, is there a list of features that are currently implemented
within the engine, but are supposed to be much more flexible
when transferred to Lua-space?
$ nl -ba boswars.bos.trunk/engine/action/action_resource.cpp
97 static bool StartGathering(CUnit *unit)
98 {
99 CUnit *goal = unit->Orders[0]->Goal;
100
101 Assert(!unit->IX && !unit->IY);
102
103 //
104 // Target is gone, stop getting resources.
105 //
106 if (!goal->IsVisibleAsGoal(unit->Player)) {
107 goal->RefsDecrease();
108 // Find an alternative, but don't look too far.
109 unit->Orders[0]->X = unit->Orders[0]->Y = -1;
110 if ((goal = UnitFindResource(unit, unit->X, unit->Y, 10))) {
111 unit->SubAction = SUB_START_RESOURCE;
112 unit->Orders[0]->Goal = goal;
113 goal->RefsIncrease();
114 } else {
115 unit->ClearAction();
116 unit->Orders[0]->Goal = NoUnitP;
117 }
118 return false;
119 }
$
--
FSF associate member #7257