Skip to content

Commit

Permalink
Merge branch 'jason'
Browse files Browse the repository at this point in the history
  • Loading branch information
selb committed Jun 2, 2023
2 parents 2c2ea89 + 239389d commit 24d6241
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 59 deletions.
24 changes: 24 additions & 0 deletions documentation/changeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@ http://onehouronelife.com/updateLog.php




Server Fixes

--Now re-sends curse token status upon reconnection. Thanks Cordy. Fixes #821

--When the container that we're holding changes size suddenly (like when riding
over something deadly that tips the horse cart), we temporarily throw the
thing on the ground before shrinking it, so that it can empty/scatter its
contents around, before deleting it from the ground. Old code made a
sometimes-incorrect assumption about where the item will be temporarily
dropped (since handleDrop respects biome boundaries), which means that
sometimes we'd go to delete this temporary object in the wrong spot, leaving
it behind in its actual spot. This is the source of the horse-cart
duplication bug. handleDrop has been changed to return the actual location
where the drop lands, and thus we can delete the temporarily-dropped horse
cart where it actually is. Thanks Doug L. and many others. Fixes #814

--Items can now have multiple +cont tags which limit them to being contained
only in particular containers. For example, the bowl of water now has both
+contFoodDish and +contLabDish, allowing it to go on both the food table and
the lab table.



Version 372 2023-05-24

--Fixed so that LivingLifePage uses visibleViewWidth for all calculations (like
Expand Down
147 changes: 88 additions & 59 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6494,8 +6494,8 @@ static void sendToolExpertMessage( LiveObject *inPlayer,



void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
SimpleVector<int> *inPlayerIndicesToSendUpdatesAbout );
GridPos handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
SimpleVector<int> *inPlayerIndicesToSendUpdatesAbout );



Expand Down Expand Up @@ -6599,8 +6599,10 @@ static int isGraveSwapDest( int inTargetX, int inTargetY,
// doesn't check for adjacency (so works for thrown drops too)
// if target spot blocked, will search for empty spot to throw object into
// if inPlayerIndicesToSendUpdatesAbout is NULL, it is ignored
void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
SimpleVector<int> *inPlayerIndicesToSendUpdatesAbout ) {
//
// Returns actual position of drop
GridPos handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
SimpleVector<int> *inPlayerIndicesToSendUpdatesAbout ) {


if( ! isBiomeAllowedForPlayer( inDroppingPlayer, inX, inY, false ) ) {
Expand Down Expand Up @@ -6725,8 +6727,7 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
}
}

int targetX = inX;
int targetY = inY;
GridPos targetPos = { inX, inY };

int mapID = getMapObject( inX, inY );
char mapSpotBlocking = false;
Expand Down Expand Up @@ -6758,8 +6759,8 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,


if( found && inDroppingPlayer->holdingID > 0 ) {
targetX = foundX;
targetY = foundY;
targetPos.x = foundX;
targetPos.y = foundY;
}
else {
// no place to drop it, it disappears
Expand Down Expand Up @@ -6807,7 +6808,7 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
if( inDroppingPlayer->numContained != 0 ) {
clearPlayerHeldContained( inDroppingPlayer );
}
return;
return targetPos;
}
}

Expand All @@ -6820,11 +6821,11 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
LiveObject *babyO = getLiveObject( babyID );

if( babyO != NULL ) {
babyO->xd = targetX;
babyO->xs = targetX;
babyO->xd = targetPos.x;
babyO->xs = targetPos.x;

babyO->yd = targetY;
babyO->ys = targetY;
babyO->yd = targetPos.y;
babyO->ys = targetPos.y;

babyO->heldByOther = false;

Expand Down Expand Up @@ -6856,7 +6857,7 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
inDroppingPlayer->heldOriginY = 0;
inDroppingPlayer->heldTransitionSourceID = -1;

return;
return targetPos;
}

setResponsiblePlayer( inDroppingPlayer->id );
Expand All @@ -6867,9 +6868,9 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
!= NULL ) {

setGravePlayerID(
targetX, targetY, inDroppingPlayer->heldGravePlayerID );
targetPos.x, targetPos.y, inDroppingPlayer->heldGravePlayerID );

int swapDest = isGraveSwapDest( targetX, targetY,
int swapDest = isGraveSwapDest( targetPos.x, targetPos.y,
inDroppingPlayer->id );

// see if another player has target location in air
Expand All @@ -6878,17 +6879,16 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
GraveMoveInfo g = {
{ inDroppingPlayer->heldGraveOriginX,
inDroppingPlayer->heldGraveOriginY },
{ targetX,
targetY },
targetPos,
swapDest };
newGraveMoves.push_back( g );
}


setMapObject( targetX, targetY, inDroppingPlayer->holdingID );
setEtaDecay( targetX, targetY, inDroppingPlayer->holdingEtaDecay );
setMapObject( targetPos.x, targetPos.y, inDroppingPlayer->holdingID );
setEtaDecay( targetPos.x, targetPos.y, inDroppingPlayer->holdingEtaDecay );

transferHeldContainedToMap( inDroppingPlayer, targetX, targetY );
transferHeldContainedToMap( inDroppingPlayer, targetPos.x, targetPos.y );



Expand All @@ -6907,11 +6907,11 @@ void handleDrop( int inX, int inY, LiveObject *inDroppingPlayer,
ObjectRecord *droppedObject = getObject( oldHoldingID );

if( inPlayerIndicesToSendUpdatesAbout != NULL ) {
handleMapChangeToPaths( targetX, targetY, droppedObject,
handleMapChangeToPaths( targetPos.x, targetPos.y, droppedObject,
inPlayerIndicesToSendUpdatesAbout );
}


return targetPos;
}


Expand Down Expand Up @@ -8542,6 +8542,8 @@ int processLoggedInPlayer( int inAllowOrForceReconnect,
o->connected = true;
o->cravingKnown = false;

o->curseTokenUpdate = true;

if( o->heldByOther ) {
// they're held, so they may have moved far away from their
// original location
Expand Down Expand Up @@ -11150,54 +11152,77 @@ static char containmentPermitted( int inContainerID, int inContainedID ) {
// not a limited containable object
return true;
}

char anyWithLimitNameFound = false;

char *limitNameLoc = &( contLoc[5] );
while( contLoc != NULL ) {


if( limitNameLoc[0] != ' ' &&
limitNameLoc[0] != '\0' ) {
char *limitNameLoc = &( contLoc[5] );

if( limitNameLoc[0] != ' ' &&
limitNameLoc[0] != '\0' ) {

// there's something after +cont
// scan the whole thing, including +cont
// there's something after +cont
// scan the whole thing, including +cont

anyWithLimitNameFound = true;

char tag[100];

int numRead = sscanf( contLoc, "%99s", tag );

if( numRead == 1 ) {
char tag[100];

// clean up # character that might delimit end of string
int tagLen = strlen( tag );
int numRead = sscanf( contLoc, "%99s", tag );

for( int i=0; i<tagLen; i++ ) {
if( tag[i] == '#' ) {
tag[i] = '\0';
tagLen = i;
break;
if( numRead == 1 ) {

// clean up # character that might delimit end of string
int tagLen = strlen( tag );

for( int i=0; i<tagLen; i++ ) {
if( tag[i] == '#' ) {
tag[i] = '\0';
tagLen = i;
break;
}
}
}

char *locInContainerName =
strstr( getObject( inContainerID )->description, tag );

if( locInContainerName != NULL ) {
// skip to end of tag
// and make sure tag isn't a sub-tag of container tag
// don't want contained to be +contHot
// and contaienr to be +contHotPlates

char end = locInContainerName[ tagLen ];
char *locInContainerName =
strstr( getObject( inContainerID )->description, tag );

if( end == ' ' ||
end == '\0'||
end == '#' ) {
return true;
if( locInContainerName != NULL ) {
// skip to end of tag
// and make sure tag isn't a sub-tag of container tag
// don't want contained to be +contHot
// and contaienr to be +contHotPlates

char end = locInContainerName[ tagLen ];

if( end == ' ' ||
end == '\0'||
end == '#' ) {
return true;
}
}
// no match with this container so far,
// but we can keep trying other +cont tags
// in our contained object
}
return false;
}
else {
// +cont with nothing after it, no limit based on this tag
}

// keep looking beyond last limit loc
contLoc = strstr( limitNameLoc, "+cont" );
}

if( anyWithLimitNameFound ) {
// item is limited to some types of container, and this
// container didn't match any of the limit names
return false;
}

// +cont with nothing after it, no limit

// we get here if we found +cont in the item, but no limit name after it
return true;
}

Expand Down Expand Up @@ -12100,13 +12125,17 @@ static void handleHoldingChange( LiveObject *inPlayer, int inNewHeldID ) {
if( found ) {

// throw it on map temporarily
handleDrop(
// spot may move based on biome bans and other factors
GridPos actualDropSpot = handleDrop(
spot.x, spot.y,
inPlayer,
// only temporary, don't worry about blocking players
// with this drop
NULL );


// use where we actually dropped it
spot = actualDropSpot;


// responsible player for stuff thrown on map by shrink
setResponsiblePlayer( inPlayer->id );
Expand Down

0 comments on commit 24d6241

Please sign in to comment.