Skip to content

Commit

Permalink
preserve old canSendMessage so examplefuncsplayer still works
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Gonzalez Hermosillo committed Jan 7, 2025
1 parent 6552b3b commit f7772fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
14 changes: 14 additions & 0 deletions engine/src/main/battlecode/common/RobotController.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,20 @@ public interface RobotController {
*/
boolean canSendMessage(MapLocation loc);

/**
* Returns true if the unit can send a message to a specific
* location, false otherwise. We can send a message to a location
* if it is within a specific distance and connected by paint,
* and only if one unit is a robot and the other is a tower.
*
* @param loc the location to send the message to
* @param messageContent the contents of the message.
* Does not affect whether or not the message can be sent.
*
* @battlecode.doc.costlymethod
*/
boolean canSendMessage(MapLocation loc, int messageContent);

/**
* Sends a message (contained in an int, so 4 bytes) to a specific
* unit at a location on the map, if it is possible
Expand Down
10 changes: 7 additions & 3 deletions engine/src/main/battlecode/world/RobotControllerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -968,13 +968,17 @@ private void assertCanSendMessage(MapLocation loc, Message message) throws GameA

@Override
public boolean canSendMessage(MapLocation loc) {
// use dummy message content as does not affect if message can be sent
return canSendMessage(loc, 0);
}

@Override
public boolean canSendMessage(MapLocation loc, int messageContent) {
try {
// use dummy message content as does not affect if message can be sent
Message message = new Message(0, this.robot.getID(), this.gameWorld.getCurrentRound());
Message message = new Message(messageContent, this.robot.getID(), this.gameWorld.getCurrentRound());
assertCanSendMessage(loc, message);
return true;
} catch (GameActionException e) {
//System.out.println(e);
return false;
}
}
Expand Down

0 comments on commit f7772fe

Please sign in to comment.