Here is why it happens.
MapView.java line 731:
- Code: Select all
public void uimsg(String msg, Object... args) {
if(msg == "move") {
move((Coord)args[0]);
if(cam != null)
cam.moved(this);
}
uimsg() is the place where all the info is received from the server in mapview. The "msg == "move" " command receives the info and updates the location of the place you port to in this line "move((Coord)args[0]);". The next line " cam.moved(this);" is called and is meant to basically update the camera position to the next location your supposed to end up at.
Depending on what type of camera you use a different method is called. But just about everyone uses Fixed Cam. The issue lies in the fixcams function "setpos".
- Code: Select all
public void setpos(MapView mv, Gob player, Coord sz) {
if(setoff) {
borderize(mv, player, sz, border);
off = mv.mc.add(player.getc().inv());
setoff = false;
}
mv.mc = player.getc().add(off);
}
public void moved(MapView mv) {
setoff = true;
}
when "moved(MapView mv)" is called the function " setpos(MapView mv, Gob player, Coord sz) " resets the camera based on this function " off = mv.mc.add(player.getc().inv());" What it basically means is that the players position is checked compared to the position of the player and a new relative offset camera position is made. This would not cause issues if the player position was updated before the camera offset calculation was made. But server side information sometimes send the new camera location before the player location and the offset is miss calculated incorrectly. What ends up happening is that the camera offset assumes the player is still back in the old location and sets an offset relative to where the camera is compared to the old player location. The offset becomes some huge number where its center is looking at the spot the player is standing on but the camera is offset to your old spot. That is why when you hit the HOME button the camera re fixates back on the player.
Here is my suggestion for a fix.
Add a global static vairable on line 86:
- Code: Select all
static boolean fixCameraBug = false; // new
add a few more lines of code in the uimsg on line 734:
from this:
- Code: Select all
if(msg == "move") {
move((Coord)args[0]);
if(cam != null)
cam.moved(this);
}
to this:
- Code: Select all
if(msg == "move") {
move((Coord)args[0]);
if(cam != null){
cam.moved(this);
fixCameraBug = true;
}
}
and lastly edit the setpos function in FixedCam line 410:
from this:
- Code: Select all
public void setpos(MapView mv, Gob player, Coord sz) {
if(setoff) {
borderize(mv, player, sz, border);
off = mv.mc.add(player.getc().inv());
setoff = false;
}
mv.mc = player.getc().add(off);
}
to this:
- Code: Select all
public void setpos(MapView mv, Gob player, Coord sz) {
if(setoff) {
borderize(mv, player, sz, border);
off = mv.mc.add(player.getc().inv());
setoff = false;
if(fixCameraBug){
fixCameraBug = false;
off = Coord.z;
}
}
mv.mc = player.getc().add(off);
}
I will suggest this to Enders and maybe he can update everyone's client with this annoying bug. He might also be able to add a few other nifty bug fixes.