TiGetClient() excessive use hotspots
This is reducing nearby calls to TiGetClient() API when the value can be looked up one time and stored in a local variable to make other decisions about. This is due to TiGetClient() potentially having a slightly higher cost to call than previously, this is a kind of peephole optimization approach (if I can see multiple getters used within the window it got optmized). 'ticlient' was used for retrieval as ClientData so that future greps across the codebase for `ti_client` should only match naked access.
This commit is contained in:
parent
606f37cc80
commit
f942ae6e78
|
|
@ -3038,10 +3038,12 @@ extTransFindSubsFunc1(tile, noderecptr)
|
||||||
* regions under the same device)
|
* regions under the same device)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (TiGetClient(tile) != extUnInit)
|
ClientData ticlient = TiGetClient(tile);
|
||||||
|
if (ticlient != extUnInit)
|
||||||
{
|
{
|
||||||
|
NodeRegion *reg = (NodeRegion *) CD2PTR(ticlient);
|
||||||
if ((noderecptr->region != (NodeRegion *)NULL) &&
|
if ((noderecptr->region != (NodeRegion *)NULL) &&
|
||||||
(noderecptr->region != TiGetClientPTR(tile)))
|
(noderecptr->region != reg))
|
||||||
TxError("Warning: Split substrate under device at (%d %d)\n",
|
TxError("Warning: Split substrate under device at (%d %d)\n",
|
||||||
tile->ti_ll.p_x, tile->ti_ll.p_y);
|
tile->ti_ll.p_x, tile->ti_ll.p_y);
|
||||||
if (IsSplit(tile))
|
if (IsSplit(tile))
|
||||||
|
|
@ -3052,7 +3054,7 @@ extTransFindSubsFunc1(tile, noderecptr)
|
||||||
else
|
else
|
||||||
type = TiGetTypeExact(tile);
|
type = TiGetTypeExact(tile);
|
||||||
|
|
||||||
noderecptr->region = (NodeRegion *)TiGetClientPTR(tile);
|
noderecptr->region = (NodeRegion *) reg;
|
||||||
noderecptr->layer = type;
|
noderecptr->layer = type;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -4906,14 +4908,15 @@ topside:
|
||||||
len = EDGENULL(&r) ? 0 : r.r_xtop - r.r_xbot;
|
len = EDGENULL(&r) ? 0 : r.r_xtop - r.r_xbot;
|
||||||
}
|
}
|
||||||
else len = MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp));
|
else len = MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp));
|
||||||
|
ClientData ticlient = TiGetClient(tp);
|
||||||
if (IsSplit(tp))
|
if (IsSplit(tp))
|
||||||
{
|
{
|
||||||
t = SplitBottomType(tp);
|
t = SplitBottomType(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILEBOTTOM(tp, tilePlaneNum);
|
PUSHTILEBOTTOM(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
|
else if ((NodeRegion *)CD2PTR(ticlient) != reg && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
/* Count split tile twice, once for each node it belongs to. */
|
/* Count split tile twice, once for each node it belongs to. */
|
||||||
TiSetClient(tp, extUnInit);
|
TiSetClient(tp, extUnInit);
|
||||||
|
|
@ -4923,7 +4926,7 @@ topside:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = TiGetTypeExact(tp);
|
t = TiGetTypeExact(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILE(tp, tilePlaneNum);
|
PUSHTILE(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
|
|
@ -4951,14 +4954,15 @@ leftside:
|
||||||
len = EDGENULL(&r) ? 0 : r.r_ytop - r.r_ybot;
|
len = EDGENULL(&r) ? 0 : r.r_ytop - r.r_ybot;
|
||||||
}
|
}
|
||||||
else len = MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp));
|
else len = MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp));
|
||||||
|
ClientData ticlient = TiGetClient(tp);
|
||||||
if (IsSplit(tp))
|
if (IsSplit(tp))
|
||||||
{
|
{
|
||||||
t = SplitRightType(tp);
|
t = SplitRightType(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILERIGHT(tp, tilePlaneNum);
|
PUSHTILERIGHT(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
|
else if ((NodeRegion *)CD2PTR(ticlient) != reg && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
/* Count split tile twice, once for each node it belongs to. */
|
/* Count split tile twice, once for each node it belongs to. */
|
||||||
TiSetClient(tp, extUnInit);
|
TiSetClient(tp, extUnInit);
|
||||||
|
|
@ -4968,7 +4972,7 @@ leftside:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = TiGetTypeExact(tp);
|
t = TiGetTypeExact(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILE(tp, tilePlaneNum);
|
PUSHTILE(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
|
|
@ -4997,14 +5001,15 @@ bottomside:
|
||||||
len = EDGENULL(&r) ? 0 : r.r_xtop - r.r_xbot;
|
len = EDGENULL(&r) ? 0 : r.r_xtop - r.r_xbot;
|
||||||
}
|
}
|
||||||
else len = MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp));
|
else len = MIN(RIGHT(tile), RIGHT(tp)) - MAX(LEFT(tile), LEFT(tp));
|
||||||
|
ClientData ticlient = TiGetClient(tp);
|
||||||
if (IsSplit(tp))
|
if (IsSplit(tp))
|
||||||
{
|
{
|
||||||
t = SplitTopType(tp);
|
t = SplitTopType(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILETOP(tp, tilePlaneNum);
|
PUSHTILETOP(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
|
else if ((NodeRegion *)CD2PTR(ticlient) != reg && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
/* Count split tile twice, once for each node it belongs to. */
|
/* Count split tile twice, once for each node it belongs to. */
|
||||||
TiSetClient(tp, extUnInit);
|
TiSetClient(tp, extUnInit);
|
||||||
|
|
@ -5014,7 +5019,7 @@ bottomside:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = TiGetTypeExact(tp);
|
t = TiGetTypeExact(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILE(tp, tilePlaneNum);
|
PUSHTILE(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
|
|
@ -5042,14 +5047,15 @@ rightside:
|
||||||
len = EDGENULL(&r) ? 0 : r.r_ytop - r.r_ybot;
|
len = EDGENULL(&r) ? 0 : r.r_ytop - r.r_ybot;
|
||||||
}
|
}
|
||||||
else len = MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp));
|
else len = MIN(TOP(tile), TOP(tp)) - MAX(BOTTOM(tile), BOTTOM(tp));
|
||||||
|
ClientData ticlient = TiGetClient(tp);
|
||||||
if (IsSplit(tp))
|
if (IsSplit(tp))
|
||||||
{
|
{
|
||||||
t = SplitLeftType(tp);
|
t = SplitLeftType(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILELEFT(tp, tilePlaneNum);
|
PUSHTILELEFT(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
else if (TiGetClientPTR(tp) != reg && TTMaskHasType(mask, t))
|
else if ((NodeRegion *)CD2PTR(ticlient) != reg && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
/* Count split tile twice, once for each node it belongs to */
|
/* Count split tile twice, once for each node it belongs to */
|
||||||
TiSetClient(tp, extUnInit);
|
TiSetClient(tp, extUnInit);
|
||||||
|
|
@ -5059,7 +5065,7 @@ rightside:
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = TiGetTypeExact(tp);
|
t = TiGetTypeExact(tp);
|
||||||
if (TiGetClient(tp) == extUnInit && TTMaskHasType(mask, t))
|
if (ticlient == extUnInit && TTMaskHasType(mask, t))
|
||||||
{
|
{
|
||||||
PUSHTILE(tp, tilePlaneNum);
|
PUSHTILE(tp, tilePlaneNum);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
107
resis/ResMain.c
107
resis/ResMain.c
|
|
@ -1443,9 +1443,13 @@ FindStartTile(goodies, SourcePoint)
|
||||||
MAX(BOTTOM(tile), BOTTOM(tp))) >> 1;
|
MAX(BOTTOM(tile), BOTTOM(tp))) >> 1;
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
{
|
||||||
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
const tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
|
if (ticlient != CLIENTDEFAULT && tj->tj_status & RES_TILE_DEV)
|
||||||
complex = TRUE;
|
complex = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* right */
|
/* right */
|
||||||
|
|
@ -1460,9 +1464,13 @@ FindStartTile(goodies, SourcePoint)
|
||||||
MAX(BOTTOM(tile), BOTTOM(tp))) >> 1;
|
MAX(BOTTOM(tile), BOTTOM(tp))) >> 1;
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
{
|
||||||
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
const tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
|
if (ticlient != CLIENTDEFAULT && tj->tj_status & RES_TILE_DEV)
|
||||||
complex = TRUE;
|
complex = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* top */
|
/* top */
|
||||||
|
|
@ -1477,9 +1485,13 @@ FindStartTile(goodies, SourcePoint)
|
||||||
MAX(LEFT(tile), LEFT(tp))) >> 1;
|
MAX(LEFT(tile), LEFT(tp))) >> 1;
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
{
|
||||||
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
const tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
|
if (ticlient != CLIENTDEFAULT && tj->tj_status & RES_TILE_DEV)
|
||||||
complex = TRUE;
|
complex = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bottom */
|
/* bottom */
|
||||||
|
|
@ -1494,9 +1506,13 @@ FindStartTile(goodies, SourcePoint)
|
||||||
MAX(LEFT(tile), LEFT(tp))) >> 1;
|
MAX(LEFT(tile), LEFT(tp))) >> 1;
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
{
|
||||||
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
const tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
|
if (ticlient != CLIENTDEFAULT && tj->tj_status & RES_TILE_DEV)
|
||||||
complex = TRUE;
|
complex = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (complex == TRUE)
|
if (complex == TRUE)
|
||||||
|
|
@ -1529,16 +1545,19 @@ FindStartTile(goodies, SourcePoint)
|
||||||
}
|
}
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
{
|
{
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
if (ticlient != CLIENTDEFAULT)
|
||||||
{
|
{
|
||||||
if (!(((tileJunk *)TiGetClientPTR(tp))->tj_status
|
tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
& RES_TILE_PUSHED))
|
if (tj->tj_status & RES_TILE_DEV)
|
||||||
{
|
{
|
||||||
((tileJunk *)TiGetClientPTR(tp))->tj_status
|
if (!(tj->tj_status & RES_TILE_PUSHED))
|
||||||
|= RES_TILE_PUSHED;
|
{
|
||||||
STACKPUSH((ClientData)tp, devStack);
|
tj->tj_status |= RES_TILE_PUSHED;
|
||||||
|
STACKPUSH((ClientData)tp, devStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1560,16 +1579,19 @@ FindStartTile(goodies, SourcePoint)
|
||||||
}
|
}
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
{
|
{
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
if (ticlient != CLIENTDEFAULT)
|
||||||
{
|
{
|
||||||
if (!(((tileJunk *)TiGetClientPTR(tp))->tj_status
|
tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
& RES_TILE_PUSHED))
|
if (tj->tj_status & RES_TILE_DEV)
|
||||||
{
|
{
|
||||||
((tileJunk *)TiGetClientPTR(tp))->tj_status
|
if (!(tj->tj_status & RES_TILE_PUSHED))
|
||||||
|= RES_TILE_PUSHED;
|
{
|
||||||
STACKPUSH((ClientData)tp, devStack);
|
tj->tj_status |= RES_TILE_PUSHED;
|
||||||
|
STACKPUSH((ClientData)tp, devStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1591,16 +1613,19 @@ FindStartTile(goodies, SourcePoint)
|
||||||
}
|
}
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
{
|
{
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
if (ticlient != CLIENTDEFAULT)
|
||||||
{
|
{
|
||||||
if (!(((tileJunk *)TiGetClientPTR(tp))->tj_status
|
tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
& RES_TILE_PUSHED))
|
if (tj->tj_status & RES_TILE_DEV)
|
||||||
{
|
{
|
||||||
((tileJunk *)TiGetClientPTR(tp))->tj_status
|
if (!(tj->tj_status & RES_TILE_PUSHED))
|
||||||
|= RES_TILE_PUSHED;
|
{
|
||||||
STACKPUSH((ClientData)tp, devStack);
|
tj->tj_status |= RES_TILE_PUSHED;
|
||||||
|
STACKPUSH((ClientData)tp, devStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1622,16 +1647,19 @@ FindStartTile(goodies, SourcePoint)
|
||||||
}
|
}
|
||||||
return(tp);
|
return(tp);
|
||||||
}
|
}
|
||||||
else if (TiGetClient(tp) != CLIENTDEFAULT)
|
else
|
||||||
{
|
{
|
||||||
if (((tileJunk *)TiGetClientPTR(tp))->tj_status & RES_TILE_DEV)
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
|
if (ticlient != CLIENTDEFAULT)
|
||||||
{
|
{
|
||||||
if (!(((tileJunk *)TiGetClientPTR(tp))->tj_status
|
tileJunk *tj = (tileJunk *)CD2PTR(ticlient);
|
||||||
& RES_TILE_PUSHED))
|
if (tj->tj_status & RES_TILE_DEV)
|
||||||
{
|
{
|
||||||
((tileJunk *)TiGetClientPTR(tp))->tj_status
|
if (!(tj->tj_status & RES_TILE_PUSHED))
|
||||||
|= RES_TILE_PUSHED;
|
{
|
||||||
STACKPUSH((ClientData)tp, devStack);
|
tj->tj_status |= RES_TILE_PUSHED;
|
||||||
|
STACKPUSH((ClientData)tp, devStack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1718,19 +1746,20 @@ ResGetDevice(pt, type)
|
||||||
tile = ResUse->cu_def->cd_planes[pnum]->pl_hint;
|
tile = ResUse->cu_def->cd_planes[pnum]->pl_hint;
|
||||||
GOTOPOINT(tile, &workingPoint);
|
GOTOPOINT(tile, &workingPoint);
|
||||||
|
|
||||||
|
const ClientData ticlient = TiGetClient(tile);
|
||||||
if (IsSplit(tile))
|
if (IsSplit(tile))
|
||||||
{
|
{
|
||||||
if (TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetLeftType(tile))
|
if (TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetLeftType(tile))
|
||||||
|| TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetRightType(tile)))
|
|| TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetRightType(tile)))
|
||||||
return (((tileJunk *)TiGetClientPTR(tile))->deviceList);
|
return (((tileJunk *)CD2PTR(ticlient))->deviceList);
|
||||||
}
|
}
|
||||||
else if (TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetType(tile)))
|
else if (TTMaskHasType(&ExtCurStyle->exts_deviceMask, TiGetType(tile)))
|
||||||
{
|
{
|
||||||
/* Failure to have a valid client data will result in a "Bad Device"
|
/* Failure to have a valid client data will result in a "Bad Device"
|
||||||
* error and indicates a problem that needs debugging.
|
* error and indicates a problem that needs debugging.
|
||||||
*/
|
*/
|
||||||
if (TiGetClient(tile) != CLIENTDEFAULT)
|
if (ticlient != CLIENTDEFAULT)
|
||||||
return (((tileJunk *)TiGetClientPTR(tile))->deviceList);
|
return (((tileJunk *)CD2PTR(ticlient))->deviceList);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -656,10 +656,10 @@ ResRemovePlumbing(tile, arg)
|
||||||
ClientData *arg;
|
ClientData *arg;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
ClientData ticlient = TiGetClient(tile);
|
||||||
if (TiGetClient(tile) != CLIENTDEFAULT)
|
if (ticlient != CLIENTDEFAULT)
|
||||||
{
|
{
|
||||||
freeMagic((char *)TiGetClientPTR(tile));
|
freeMagic((char *)CD2PTR(ticlient));
|
||||||
TiSetClient(tile, CLIENTDEFAULT);
|
TiSetClient(tile, CLIENTDEFAULT);
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
|
|
@ -845,8 +845,9 @@ tileJunk *
|
||||||
resAddField(tile)
|
resAddField(tile)
|
||||||
Tile *tile;
|
Tile *tile;
|
||||||
{
|
{
|
||||||
tileJunk *Junk;
|
ClientData ticlient = TiGetClient(tile);
|
||||||
if ((Junk = (tileJunk *)TiGetClientPTR(tile)) == (tileJunk *) CLIENTDEFAULT)
|
tileJunk *Junk = (tileJunk *)CD2PTR(ticlient);
|
||||||
|
if (ticlient == CLIENTDEFAULT)
|
||||||
{
|
{
|
||||||
Junk = (tileJunk *) mallocMagic((unsigned) (sizeof(tileJunk)));
|
Junk = (tileJunk *) mallocMagic((unsigned) (sizeof(tileJunk)));
|
||||||
ResJunkInit(Junk);
|
ResJunkInit(Junk);
|
||||||
|
|
|
||||||
|
|
@ -413,9 +413,10 @@ selShortTileProc(tile, ssd)
|
||||||
Tile *tile;
|
Tile *tile;
|
||||||
ShortSearchData *ssd;
|
ShortSearchData *ssd;
|
||||||
{
|
{
|
||||||
if ((int)TiGetClientINT(tile) < ssd->cost)
|
const int curr = (int)TiGetClientINT(tile);
|
||||||
|
if (curr < ssd->cost)
|
||||||
{
|
{
|
||||||
ssd->cost = (int)TiGetClientINT(tile);
|
ssd->cost = curr;
|
||||||
ssd->tile = tile;
|
ssd->tile = tile;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -518,10 +519,12 @@ selShortFindReverse(rlist, tile, pnum, fdir)
|
||||||
|
|
||||||
for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp))
|
for (tp = RT(tile); RIGHT(tp) > LEFT(tile); tp = BL(tp))
|
||||||
{
|
{
|
||||||
if (TiGetClient(tp) == CLIENTDEFAULT) continue;
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
if ((int)TiGetClientINT(tp) < mincost)
|
if (ticlient == CLIENTDEFAULT) continue;
|
||||||
|
const int curr = (int)CD2INT(ticlient);
|
||||||
|
if (curr < mincost)
|
||||||
{
|
{
|
||||||
mincost = (int)TiGetClientINT(tp);
|
mincost = curr;
|
||||||
mintp = tp;
|
mintp = tp;
|
||||||
mindir = GEO_NORTH;
|
mindir = GEO_NORTH;
|
||||||
}
|
}
|
||||||
|
|
@ -538,10 +541,12 @@ leftside:
|
||||||
|
|
||||||
for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp))
|
for (tp = BL(tile); BOTTOM(tp) < TOP(tile); tp = RT(tp))
|
||||||
{
|
{
|
||||||
if (TiGetClient(tp) == CLIENTDEFAULT) continue;
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
if ((int)TiGetClientINT(tp) < mincost)
|
if (ticlient == CLIENTDEFAULT) continue;
|
||||||
|
const int curr = (int)CD2INT(ticlient);
|
||||||
|
if (curr < mincost)
|
||||||
{
|
{
|
||||||
mincost = (int)TiGetClientINT(tp);
|
mincost = curr;
|
||||||
mintp = tp;
|
mintp = tp;
|
||||||
mindir = GEO_WEST;
|
mindir = GEO_WEST;
|
||||||
}
|
}
|
||||||
|
|
@ -558,10 +563,12 @@ bottomside:
|
||||||
|
|
||||||
for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp = TR(tp))
|
for (tp = LB(tile); LEFT(tp) < RIGHT(tile); tp = TR(tp))
|
||||||
{
|
{
|
||||||
if (TiGetClient(tp) == CLIENTDEFAULT) continue;
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
if ((int)TiGetClientINT(tp) < mincost)
|
if (ticlient == CLIENTDEFAULT) continue;
|
||||||
|
const int curr = (int)CD2INT(ticlient);
|
||||||
|
if (curr < mincost)
|
||||||
{
|
{
|
||||||
mincost = (int)TiGetClientINT(tp);
|
mincost = curr;
|
||||||
mintp = tp;
|
mintp = tp;
|
||||||
mindir = GEO_SOUTH;
|
mindir = GEO_SOUTH;
|
||||||
}
|
}
|
||||||
|
|
@ -578,10 +585,12 @@ rightside:
|
||||||
|
|
||||||
for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp = LB(tp))
|
for (tp = TR(tile); TOP(tp) > BOTTOM(tile); tp = LB(tp))
|
||||||
{
|
{
|
||||||
if (TiGetClient(tp) == CLIENTDEFAULT) continue;
|
const ClientData ticlient = TiGetClient(tp);
|
||||||
if ((int)TiGetClientINT(tp) < mincost)
|
if (ticlient == CLIENTDEFAULT) continue;
|
||||||
|
const int curr = (int)CD2INT(ticlient);
|
||||||
|
if (curr < mincost)
|
||||||
{
|
{
|
||||||
mincost = (int)TiGetClientINT(tp);
|
mincost = curr;
|
||||||
mintp = tp;
|
mintp = tp;
|
||||||
mindir = GEO_EAST;
|
mindir = GEO_EAST;
|
||||||
}
|
}
|
||||||
|
|
@ -748,9 +757,11 @@ selShortProcessTile(tile, cost, fdir, mask)
|
||||||
/* If this tile is unvisited, or has a lower cost, then return and */
|
/* If this tile is unvisited, or has a lower cost, then return and */
|
||||||
/* keep going. Otherwise, return 1 to stop the search this direction */
|
/* keep going. Otherwise, return 1 to stop the search this direction */
|
||||||
|
|
||||||
if (TiGetClient(tile) == CLIENTDEFAULT)
|
const ClientData ticlient = TiGetClient(tile);
|
||||||
|
const int curr = (int)CD2INT(ticlient);
|
||||||
|
if (ticlient == CLIENTDEFAULT)
|
||||||
TiSetClientINT(tile, cost);
|
TiSetClientINT(tile, cost);
|
||||||
else if ((int)TiGetClientINT(tile) > cost)
|
else if (curr > cost)
|
||||||
TiSetClientINT(tile, cost);
|
TiSetClientINT(tile, cost);
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue