Emberveil sourcetests/GodWarsClientSmoke.java
import java.net.InetAddress;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;
/** Real encrypted login and world-loading check on the isolated world-99 server. */
public final class GodWarsClientSmoke extends Game {
static String username;
int ticks;boolean attempted;
java.util.Set<Integer> sampledNpcs=new java.util.HashSet<>();
static int objectId=-1,objectX,objectY;
@Override public void processGameLoop(){
if(!attempted){attempted=true;myUsername=username;myPassword="gwd-local-qa";loginScreenState=2;login(myUsername,myPassword,false);
if(!loggedIn){System.err.println("FAIL login: "+loginMessage1+" "+loginMessage2);System.exit(1);}}
super.processGameLoop();
if(loggedIn&&loadingStage==2&&ticks<=100)for(int i=0;i<npcCount;i++){NPC npc=npcArray[npcIndices[i]];if(npc!=null&&npc.desc!=null&&npc.desc.type>=3900&&npc.desc.type<=3980){npc.getRotatedModel();if(ticks==100)sampledNpcs.add(npcIndices[i]);}}
anInt1184=320;minimapInt1=0;
if(loggedIn&&loadingStage==2&&ticks==30&&objectId>=0){
int tag=worldController.method302(plane,objectX-baseX,objectY-baseY);
if(tag==0)tag=worldController.method300(plane,objectX-baseX,objectY-baseY);
if((tag>>14&0x7fff)!=objectId)throw new AssertionError("Object ID does not survive scene-tag packing");
stream.createFrame(132);stream.method433(objectX);stream.writeWord(objectId);stream.method432(objectY);
}
if(loggedIn&&loadingStage==2&&ticks==80&&(username.equals("gwdqa0")||username.equals("gwdqa5"))){stream.createFrame(185);stream.writeWord(username.equals("gwdqa0")?7662:7687);}
if(loggedIn&&loadingStage==2&&++ticks==150){
try{
int visible=0;for(int i=0;i<npcCount;i++){NPC npc=npcArray[npcIndices[i]];if(npc!=null&&npc.desc!=null&&npc.desc.type>=3900&&npc.desc.type<=3980){visible++;if(sampledNpcs.contains(npcIndices[i])&&npc.getRotatedModel()==null)throw new AssertionError("Missing NPC model "+npc.desc.type+" "+npc.desc.name);}}
if(!username.equals("gwdqa5")&&visible==0)throw new AssertionError("No GWD NPCs received");
boolean spear=username.equals("gwdqa0");
if(tabInterfaceIDs[0]!=(spear?4679:4705)||RSInterface.interfaceCache[spear?7674:7699].aBoolean266)throw new AssertionError("Weapon attack panel or special bar missing");
if((spear||username.equals("gwdqa5"))&&!RSInterface.interfaceCache[spear?7686:7711].disabledText.contains("@yel@"))throw new AssertionError("Real client special button did not activate");
boolean welcome=false;for(String message:chatMessages)if(message!=null&&message.contains("Welcome to")&&message.contains("Owner:")&&message.contains("bonds"))welcome=true;
if(!welcome)throw new AssertionError("Owner credit missing from login welcome");
if(objectId>=0&&username.equals("gwdqa5")&&(baseX+myPlayer.smallX[0]!=2882||baseY+myPlayer.smallY[0]!=5311||plane!=2))throw new AssertionError("Entrance click did not reach dungeon");
RSImageProducer view=aRSImageProducer_1165;BufferedImage image=new BufferedImage(512,334,BufferedImage.TYPE_INT_RGB);
image.setRGB(0,0,512,334,view.anIntArray315,0,512);
ImageIO.write(image,"png",new File("runtime/godwars-stage/client-"+username+".png"));
System.out.println("CLIENT PASS: "+username+" world rendered, GWD NPCs="+visible+" position="+(baseX+myPlayer.smallX[0])+","+(baseY+myPlayer.smallY[0])+","+plane);
System.exit(0);
}catch(Throwable failure){failure.printStackTrace();System.exit(1);}
}
}
public static void main(String[] args)throws Exception {
username=args[0];if(!username.matches("gwdqa[0-5]"))throw new IllegalArgumentException("Staged fixtures only");
if(args.length>1){objectId=Integer.parseInt(args[1]);objectX=Integer.parseInt(args[2]);objectY=Integer.parseInt(args[3]);}
ClientSettings.SERVER_IP="127.0.0.1";ClientSettings.CHECK_CRC=false;ClientSettings.SHOW_NAVBAR=false;ClientSettings.HIDE_ROOFS=true;
ClientSettings.SERVER_WORLD=99;Game.nodeID=10;Game.portOff=0;Game.setHighMem();Game.isMembers=true;
Signlink.storeid=32;Signlink.startpriv(InetAddress.getLocalHost());new GodWarsClientSmoke().createClientFrame(503,765);
Thread timeout=new Thread(()->{try{Thread.sleep(60000);}catch(Exception ignored){}System.err.println("FAIL: client timeout");System.exit(2);});timeout.setDaemon(true);timeout.start();
}
}