Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Update Progress:
- public void updateProgress(MapleMap next, MapleMap from) {
- if (MapleRace.getMinutesUntilBegin() < 0) { // if they try to start early, wat
- if (next.getId() != map.getLeft()) //at this point, this is basically saying if it isnt the first map of the race
- racer.getCharacter().changeMap(from);
- return;
- }
- //a check if they reach the end of a list
- synchronized(this) { //order is crucial here, multi-threaded "photo finish" moment.
- if (next.getId() == racing_track.get((stage - 1)).get(racing_track.get((stage - 1)).size()).getLeft()) {
- if (MapleRace.STAGES_USE > stage) { //if they have more to go
- ++stage;
- MapleRace.announce("Racer #" + racer.getRacingId() + " has moved on to stage " + stage + " of the Great Maple Race!");
- racer.getCharacter().changeMap(ChannelServer.getInstance(1).getMapFactory().getMap(racing_track.get((stage - 1)).get(0).getLeft()));
- } else {
- MapleRace.announce("Racer #" + racer.getRacingId() + " has won the Great Maple Race!!! Please give him/her a huge congratulations!");
- racer.award();
- MapleRace.end();
- }
- }
- }
- Pair<Integer, Integer> update = new Pair<>(next.getId(), (point + 1));
- if (racing_track.get((stage - 1)).contains(update)) { //checks for valid global coordinate
- ++point;
- this.map = update;
- MapleRace.announce("Racer #" + racer.getRacingId() + " has progressed to " + next.getMapName() + " (point " + point + ")");
- } else {
- client.MapleCharacter c = racer.getCharacter();
- c.dropMessage(6, "You're going the wrong way!!! Follow the map! Head east!");
- int sendBack = racing_track.get((stage - 1)).contains(new Pair<>(from.getId(), point)) ? map.getLeft() : racing_track.get(0).get(0).getLeft();
- this.map = new Pair<>(sendBack, 1);
- c.changeMap(ChannelServer.getInstance(1).getMapFactory().getMap(sendBack)); // previous map or beginning
- }
- }
- ________________
- Change map:
- private void changeMapInternal(final MapleMap to, final Point pos, byte[] warpPacket, final MaplePortal pto) {
- if (to == null || MapleRace.getMinutesUntilBegin() < 0 && MapleRace.getMinutesUntilBegin() > -2 && getRacerIdentity() != null) {
- return;
- }
- final int nowmapid = map.getId();
- if (eventInstance != null) {
- eventInstance.changedMap(this, to.getId());
- }
- final boolean pyramid = pyramidSubway != null;
- if (map.getId() == nowmapid) {
- client.getSession().write(warpPacket);
- final boolean shouldChange = !isClone() && client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null;
- final boolean shouldState = map.getId() == to.getId();
- if (shouldChange && shouldState) {
- to.setCheckStates(false);
- }
- map.removePlayer(this);
- if (shouldChange) {
- map = to;
- setPosition(pos);
- to.addPlayer(this);
- stats.relocHeal(this);
- if (shouldState) {
- to.setCheckStates(true);
- }
- }
- }
- if (this.getRacingId() > -1 && this.getRacerIdentity() != null) {
- getRacerIdentity().getProgress().updateProgress(to, map);
- }
- if (pyramid && pyramidSubway != null) { //checks if they had pyramid before AND after changing
- pyramidSubway.onChangeMap(this, to.getId());
- }
- }
Add Comment
Please, Sign In to add comment