Stupid camera bug fix

The worst monsters in the Hearthlands warp the fabric of space and time..

Stupid camera bug fix

Postby Xcom » Thu Jul 11, 2013 12:13 am

You ever had that bug where you walk in or out of a house, minehole or teleport and you end up staring into the void. Thats because of a camera bug found in the client code.

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.
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Re: Stupid camera bug fix

Postby DDDsDD999 » Thu Jul 11, 2013 12:32 am

Xcom wrote:Depending on what type of camera you use a different method is called. But just about everyone uses Fixed Cam.

Pfft, freestyle is the gentleman's camera.

Cool fix, would be nice if someone compiled a jar of it from ender's.
Image
Image
Image
Image
Image
User avatar
DDDsDD999
 
Posts: 5670
Joined: Fri Jul 02, 2010 12:31 am

Re: Stupid camera bug fix

Postby Xcom » Thu Jul 11, 2013 12:58 am

After having a good look through I found other camera types that has the same problem. Issue is that borderize function is supposed to reset the camera in most instances if the player is out of view range. But that function can be disabled in the options window.
User avatar
Xcom
 
Posts: 1105
Joined: Wed Dec 14, 2011 1:43 pm

Re: Stupid camera bug fix

Postby windmaker » Thu Jul 11, 2013 6:05 pm

thanks sir ... i apply this patch nao :3
Image #swag
User avatar
windmaker
 
Posts: 1855
Joined: Thu Mar 29, 2012 7:08 am
Location: in the forum where some mods are fags.

Re: Stupid camera bug fix

Postby overtyped » Fri Jul 12, 2013 6:18 am

I can't find the file that I'm supposed to edit.
You do not have the required permissions to view the files attached to this post.
Early world exploit: Put your hearthfire inside a cave, then hold shift to position a claim right in front of a cave. After 8 hours the claim will be unbreakable. Since your hearthfire is inside the cave, you can still get back inside, and leave, but nobody will be able to enter, effectively making you unraidable for the first 3-7 days. Enjoy
User avatar
overtyped
 
Posts: 3906
Joined: Tue Sep 28, 2010 2:09 am
Location: Quaran book burning festival

Re: Stupid camera bug fix

Postby borka » Fri Jul 12, 2013 8:57 am

MapView.java you'll find in Source Code only ... i.e. https://github.com/EnderWiggin/Haven-an ... pView.java

;)
User avatar
borka
 
Posts: 9965
Joined: Thu Feb 03, 2011 7:47 pm
Location: World of Sprucecap

Re: Stupid camera bug fix

Postby overtyped » Fri Jul 12, 2013 7:10 pm

borka wrote:MapView.java you'll find in Source Code only ... i.e. https://github.com/EnderWiggin/Haven-an ... pView.java

;)

How do i implement this into my client?
Early world exploit: Put your hearthfire inside a cave, then hold shift to position a claim right in front of a cave. After 8 hours the claim will be unbreakable. Since your hearthfire is inside the cave, you can still get back inside, and leave, but nobody will be able to enter, effectively making you unraidable for the first 3-7 days. Enjoy
User avatar
overtyped
 
Posts: 3906
Joined: Tue Sep 28, 2010 2:09 am
Location: Quaran book burning festival

Re: Stupid camera bug fix

Postby borka » Sat Jul 13, 2013 2:22 am

you would need to pull the source (i.e. with SmartGit), edit the MapView.java and then compile the client yourself (i.e. with Ant)
User avatar
borka
 
Posts: 9965
Joined: Thu Feb 03, 2011 7:47 pm
Location: World of Sprucecap

Re: Stupid camera bug fix

Postby Nummy » Wed Aug 07, 2013 11:38 am

Can someone implement this into Enders client? Anyone with access to his source tree?
User avatar
Nummy
 
Posts: 489
Joined: Sat Mar 19, 2011 10:01 am

Re: Stupid camera bug fix

Postby borka » Wed Aug 07, 2013 8:15 pm

W.I.P. - you got a PM Nummy
Avatar by SacreDoom
Java 8 - manually downloads - good to check for actual versions url here:
viewtopic.php?f=42&t=40331
Remember what the dormouse said: Feed your head Feed your head
User avatar
borka
 
Posts: 9965
Joined: Thu Feb 03, 2011 7:47 pm
Location: World of Sprucecap

Next

Return to Bugs

Who is online

Users browsing this forum: Claude [Bot] and 3 guests