0

Hello Lambda!

This commit is contained in:
2018-03-08 19:18:46 +03:00
parent 8d9401874f
commit 5865259e9b
17 changed files with 679 additions and 1220 deletions

View File

@@ -104,26 +104,24 @@ public final class CL {
* *
* Stop recording a demo. * Stop recording a demo.
*/ */
static Runnable Stop_f = new Runnable() { static Runnable Stop_f = () -> {
public void run() { try {
try {
int len; int len;
if (!Globals.cls.demorecording) { if (!Globals.cls.demorecording) {
log.info("Not recording a demo."); log.info("Not recording a demo.");
return; return;
}
// finish up
len = -1;
Globals.cls.demofile.writeInt(EndianHandler.swapInt(len));
Globals.cls.demofile.close();
Globals.cls.demofile = null;
Globals.cls.demorecording = false;
log.info("Stopped demo.");
} catch (IOException e) {
} }
// finish up
len = -1;
Globals.cls.demofile.writeInt(EndianHandler.swapInt(len));
Globals.cls.demofile.close();
Globals.cls.demofile = null;
Globals.cls.demorecording = false;
log.info("Stopped demo.");
} catch (IOException e) {
} }
}; };
@@ -135,191 +133,181 @@ public final class CL {
* record <demoname> * record <demoname>
* Begins recording a demo from the current position. * Begins recording a demo from the current position.
*/ */
static Runnable Record_f = new Runnable() { static Runnable Record_f = () -> {
public void run() { try {
try { String name;
String name; byte buf_data[] = new byte[Defines.MAX_MSGLEN];
byte buf_data[] = new byte[Defines.MAX_MSGLEN]; sizebuf_t buf = new sizebuf_t();
sizebuf_t buf = new sizebuf_t(); int i;
int i; entity_state_t ent;
entity_state_t ent;
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
log.info("record <demoname>"); log.info("record <demoname>");
return; return;
} }
if (Globals.cls.demorecording) { if (Globals.cls.demorecording) {
log.info("Already recording."); log.info("Already recording.");
return; return;
} }
if (Globals.cls.state != Defines.ca_active) { if (Globals.cls.state != Defines.ca_active) {
log.info("You must be in a level to record."); log.info("You must be in a level to record.");
return; return;
} }
// //
// open the demo file // open the demo file
// //
name = fileSystem.getGamedir() + "/demos/" + Cmd.Argv(1) + ".dm2"; name = fileSystem.getGamedir() + "/demos/" + Cmd.Argv(1) + ".dm2";
log.info("recording to {}", name); log.info("recording to {}", name);
fileSystem.createPath(name); fileSystem.createPath(name);
Globals.cls.demofile = new RandomAccessFile(name, "rw"); Globals.cls.demofile = new RandomAccessFile(name, "rw");
if (Globals.cls.demofile == null) { if (Globals.cls.demofile == null) {
log.error("ERROR: couldn't open."); log.error("ERROR: couldn't open.");
return; return;
} }
Globals.cls.demorecording = true; Globals.cls.demorecording = true;
// don't start saving messages until a non-delta compressed // don't start saving messages until a non-delta compressed
// message is received // message is received
Globals.cls.demowaiting = true; Globals.cls.demowaiting = true;
// //
// write out messages to hold the startup information // write out messages to hold the startup information
// //
SZ.Init(buf, buf_data, Defines.MAX_MSGLEN); SZ.Init(buf, buf_data, Defines.MAX_MSGLEN);
// send the serverdata // send the serverdata
MSG.WriteByte(buf, Defines.svc_serverdata); MSG.WriteByte(buf, Defines.svc_serverdata);
MSG.WriteInt(buf, Defines.PROTOCOL_VERSION); MSG.WriteInt(buf, Defines.PROTOCOL_VERSION);
MSG.WriteInt(buf, 0x10000 + Globals.cl.servercount); MSG.WriteInt(buf, 0x10000 + Globals.cl.servercount);
MSG.WriteByte(buf, 1); // demos are always attract loops MSG.WriteByte(buf, 1); // demos are always attract loops
MSG.WriteString(buf, Globals.cl.gamedir); MSG.WriteString(buf, Globals.cl.gamedir);
MSG.WriteShort(buf, Globals.cl.playernum); MSG.WriteShort(buf, Globals.cl.playernum);
MSG.WriteString(buf, Globals.cl.configstrings[Defines.CS_NAME]); MSG.WriteString(buf, Globals.cl.configstrings[Defines.CS_NAME]);
// configstrings // configstrings
for (i = 0; i < Defines.MAX_CONFIGSTRINGS; i++) { for (i = 0; i < Defines.MAX_CONFIGSTRINGS; i++) {
if (Globals.cl.configstrings[i].length() > 0) { if (Globals.cl.configstrings[i].length() > 0) {
if (buf.cursize + Globals.cl.configstrings[i].length() if (buf.cursize + Globals.cl.configstrings[i].length()
+ 32 > buf.maxsize) { + 32 > buf.maxsize) {
// write it out // write it out
Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize));
Globals.cls.demofile
.write(buf.data, 0, buf.cursize);
buf.cursize = 0;
}
MSG.WriteByte(buf, Defines.svc_configstring);
MSG.WriteShort(buf, i);
MSG.WriteString(buf, Globals.cl.configstrings[i]);
}
}
// baselines
nullstate.clear();
for (i = 0; i < Defines.MAX_EDICTS; i++) {
ent = Globals.cl_entities[i].baseline;
if (ent.modelindex == 0)
continue;
if (buf.cursize + 64 > buf.maxsize) { // write it out
Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize)); Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize));
Globals.cls.demofile.write(buf.data, 0, buf.cursize); Globals.cls.demofile
.write(buf.data, 0, buf.cursize);
buf.cursize = 0; buf.cursize = 0;
} }
MSG.WriteByte(buf, Defines.svc_spawnbaseline); MSG.WriteByte(buf, Defines.svc_configstring);
MSG.WriteDeltaEntity(nullstate, MSG.WriteShort(buf, i);
Globals.cl_entities[i].baseline, buf, true, true); MSG.WriteString(buf, Globals.cl.configstrings[i]);
} }
MSG.WriteByte(buf, Defines.svc_stufftext);
MSG.WriteString(buf, "precache\n");
// write it to the demo file
Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize));
Globals.cls.demofile.write(buf.data, 0, buf.cursize);
// the rest of the demo file will be individual frames
} catch (IOException e) {
} }
// baselines
nullstate.clear();
for (i = 0; i < Defines.MAX_EDICTS; i++) {
ent = Globals.cl_entities[i].baseline;
if (ent.modelindex == 0)
continue;
if (buf.cursize + 64 > buf.maxsize) { // write it out
Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize));
Globals.cls.demofile.write(buf.data, 0, buf.cursize);
buf.cursize = 0;
}
MSG.WriteByte(buf, Defines.svc_spawnbaseline);
MSG.WriteDeltaEntity(nullstate,
Globals.cl_entities[i].baseline, buf, true, true);
}
MSG.WriteByte(buf, Defines.svc_stufftext);
MSG.WriteString(buf, "precache\n");
// write it to the demo file
Globals.cls.demofile.writeInt(EndianHandler.swapInt(buf.cursize));
Globals.cls.demofile.write(buf.data, 0, buf.cursize);
// the rest of the demo file will be individual frames
} catch (IOException e) {
} }
}; };
/** /**
* ForwardToServer_f * ForwardToServer_f
*/ */
static Runnable ForwardToServer_f = new Runnable() { static Runnable ForwardToServer_f = () -> {
public void run() { if (Globals.cls.state != Defines.ca_connected
if (Globals.cls.state != Defines.ca_connected && Globals.cls.state != Defines.ca_active) {
&& Globals.cls.state != Defines.ca_active) { log.warn("Can't \"{}\", not connected", Cmd.Argv(0));
log.warn("Can't \"{}\", not connected", Cmd.Argv(0)); return;
return; }
}
// don't forward the first argument // don't forward the first argument
if (Cmd.Argc() > 1) { if (Cmd.Argc() > 1) {
MSG.WriteByte(Globals.cls.netchan.message, MSG.WriteByte(Globals.cls.netchan.message,
Defines.clc_stringcmd); Defines.clc_stringcmd);
SZ.Print(Globals.cls.netchan.message, Cmd.Args()); SZ.Print(Globals.cls.netchan.message, Cmd.Args());
}
} }
}; };
/** /**
* Pause_f * Pause_f
*/ */
static Runnable Pause_f = new Runnable() { static Runnable Pause_f = () -> {
public void run() { // never pause in multiplayer
// never pause in multiplayer
if (Cvar.VariableValue("maxclients") > 1 if (Cvar.VariableValue("maxclients") > 1
|| Globals.server_state == 0) { || Globals.server_state == 0) {
Cvar.SetValue("paused", 0); Cvar.SetValue("paused", 0);
return; return;
}
Cvar.SetValue("paused", Globals.cl_paused.value);
} }
Cvar.SetValue("paused", Globals.cl_paused.value);
}; };
/** /**
* Quit_f * Quit_f
*/ */
static Runnable Quit_f = new Runnable() { static Runnable Quit_f = () -> {
public void run() { Disconnect();
Disconnect(); Com.Quit();
Com.Quit();
}
}; };
/** /**
* Connect_f * Connect_f
*/ */
static Runnable Connect_f = new Runnable() { static Runnable Connect_f = () -> {
public void run() { String server;
String server;
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
log.info("usage: connect <server>"); log.info("usage: connect <server>");
return; return;
}
if (Globals.server_state != 0) {
// if running a local server, kill it and reissue
SV_MAIN.SV_Shutdown("Server quit\n", false);
} else {
Disconnect();
}
server = Cmd.Argv(1);
NET.Config(true); // allow remote
Disconnect();
Globals.cls.state = Defines.ca_connecting;
//strncpy (cls.servername, server, sizeof(cls.servername)-1);
Globals.cls.servername = server;
Globals.cls.connect_time = -99999;
// CL_CheckForResend() will fire immediately
} }
if (Globals.server_state != 0) {
// if running a local server, kill it and reissue
SV_MAIN.SV_Shutdown("Server quit\n", false);
} else {
Disconnect();
}
server = Cmd.Argv(1);
NET.Config(true); // allow remote
Disconnect();
Globals.cls.state = Defines.ca_connecting;
//strncpy (cls.servername, server, sizeof(cls.servername)-1);
Globals.cls.servername = server;
Globals.cls.connect_time = -99999;
// CL_CheckForResend() will fire immediately
}; };
/** /**
@@ -327,77 +315,69 @@ public final class CL {
* *
* Send the rest of the command line over as an unconnected command. * Send the rest of the command line over as an unconnected command.
*/ */
static Runnable Rcon_f = new Runnable() { static Runnable Rcon_f = () -> {
public void run() {
if (Globals.rcon_client_password.string.length() == 0) { if (Globals.rcon_client_password.string.length() == 0) {
log.warn("You must set 'rcon_password' before\nissuing an rcon command."); log.warn("You must set 'rcon_password' before\nissuing an rcon command.");
return;
}
StringBuffer message = new StringBuffer(1024);
// connection less packet
message.append('\u00ff');
message.append('\u00ff');
message.append('\u00ff');
message.append('\u00ff');
// allow remote
NET.Config(true);
message.append("rcon ");
message.append(Globals.rcon_client_password.string);
message.append(" ");
for (int i = 1; i < Cmd.Argc(); i++) {
message.append(Cmd.Argv(i));
message.append(" ");
}
netadr_t to = new netadr_t();
if (Globals.cls.state >= Defines.ca_connected)
to = Globals.cls.netchan.remote_address;
else {
if (Globals.rcon_address.string.length() == 0) {
log.warn("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands");
return; return;
} }
NET.StringToAdr(Globals.rcon_address.string, to);
StringBuffer message = new StringBuffer(1024); if (to.port == 0) to.port = Defines.PORT_SERVER;
// connection less packet
message.append('\u00ff');
message.append('\u00ff');
message.append('\u00ff');
message.append('\u00ff');
// allow remote
NET.Config(true);
message.append("rcon ");
message.append(Globals.rcon_client_password.string);
message.append(" ");
for (int i = 1; i < Cmd.Argc(); i++) {
message.append(Cmd.Argv(i));
message.append(" ");
}
netadr_t to = new netadr_t();
if (Globals.cls.state >= Defines.ca_connected)
to = Globals.cls.netchan.remote_address;
else {
if (Globals.rcon_address.string.length() == 0) {
log.warn("You must either be connected,\nor set the 'rcon_address' cvar\nto issue rcon commands");
return;
}
NET.StringToAdr(Globals.rcon_address.string, to);
if (to.port == 0) to.port = Defines.PORT_SERVER;
}
message.append('\0');
String b = message.toString();
NET.SendPacket(Defines.NS_CLIENT, b.length(), Lib.stringToBytes(b), to);
} }
message.append('\0');
String b = message.toString();
NET.SendPacket(Defines.NS_CLIENT, b.length(), Lib.stringToBytes(b), to);
}; };
static Runnable Disconnect_f = new Runnable() { static Runnable Disconnect_f = () -> Com.Error(Defines.ERR_DROP, "Disconnected from server");
public void run() {
Com.Error(Defines.ERR_DROP, "Disconnected from server");
}
};
/** /**
* Changing_f * Changing_f
* *
* Just sent as a hint to the client that they should drop to full console. * Just sent as a hint to the client that they should drop to full console.
*/ */
static Runnable Changing_f = new Runnable() { static Runnable Changing_f = () -> {
public void run() { //ZOID
//ZOID //if we are downloading, we don't change!
//if we are downloading, we don't change! // This so we don't suddenly stop downloading a map
// This so we don't suddenly stop downloading a map
if (Globals.cls.download != null) if (Globals.cls.download != null)
return; return;
SCR.BeginLoadingPlaque(); SCR.BeginLoadingPlaque();
Globals.cls.state = Defines.ca_connected; // not active anymore, but Globals.cls.state = Defines.ca_connected; // not active anymore, but
// not disconnected // not disconnected
log.info("Changing map..."); log.info("Changing map...");
}
}; };
/** /**
@@ -405,93 +385,89 @@ public final class CL {
* *
* The server is changing levels. * The server is changing levels.
*/ */
static Runnable Reconnect_f = new Runnable() { static Runnable Reconnect_f = () -> {
public void run() { //ZOID
//ZOID //if we are downloading, we don't change! This so we don't suddenly
//if we are downloading, we don't change! This so we don't suddenly // stop downloading a map
// stop downloading a map if (Globals.cls.download != null)
if (Globals.cls.download != null) return;
return;
S.StopAllSounds(); S.StopAllSounds();
if (Globals.cls.state == Defines.ca_connected) { if (Globals.cls.state == Defines.ca_connected) {
log.info("reconnecting..."); log.info("reconnecting...");
Globals.cls.state = Defines.ca_connected; Globals.cls.state = Defines.ca_connected;
MSG.WriteChar(Globals.cls.netchan.message, MSG.WriteChar(Globals.cls.netchan.message,
Defines.clc_stringcmd); Defines.clc_stringcmd);
MSG.WriteString(Globals.cls.netchan.message, "new"); MSG.WriteString(Globals.cls.netchan.message, "new");
return; return;
} }
if (Globals.cls.servername != null) { if (Globals.cls.servername != null) {
if (Globals.cls.state >= Defines.ca_connected) { if (Globals.cls.state >= Defines.ca_connected) {
Disconnect(); Disconnect();
Globals.cls.connect_time = Globals.cls.realtime - 1500; Globals.cls.connect_time = Globals.cls.realtime - 1500;
} else } else
Globals.cls.connect_time = -99999; // fire immediately Globals.cls.connect_time = -99999; // fire immediately
Globals.cls.state = Defines.ca_connecting; Globals.cls.state = Defines.ca_connecting;
log.info("reconnecting..."); log.info("reconnecting...");
}
} }
}; };
/** /**
* PingServers_f * PingServers_f
*/ */
static Runnable PingServers_f = new Runnable() { static Runnable PingServers_f = () -> {
public void run() { int i;
int i; netadr_t adr = new netadr_t();
netadr_t adr = new netadr_t(); //char name[32];
//char name[32]; String name;
String name; String adrstring;
String adrstring; cvar_t noudp;
cvar_t noudp; cvar_t noipx;
cvar_t noipx;
NET.Config(true); // allow remote NET.Config(true); // allow remote
// send a broadcast packet // send a broadcast packet
log.info("pinging broadcast..."); log.info("pinging broadcast...");
noudp = Cvar.Get("noudp", "0", Defines.CVAR_NOSET); noudp = Cvar.Get("noudp", "0", Defines.CVAR_NOSET);
if (noudp.value == 0.0f) { if (noudp.value == 0.0f) {
adr.type = Defines.NA_BROADCAST; adr.type = Defines.NA_BROADCAST;
adr.port = Defines.PORT_SERVER; adr.port = Defines.PORT_SERVER;
//adr.port = BigShort(PORT_SERVER); //adr.port = BigShort(PORT_SERVER);
Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info " Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info "
+ Defines.PROTOCOL_VERSION); + Defines.PROTOCOL_VERSION);
}
// we use no IPX
noipx = Cvar.Get("noipx", "1", Defines.CVAR_NOSET);
if (noipx.value == 0.0f) {
adr.type = Defines.NA_BROADCAST_IPX;
//adr.port = BigShort(PORT_SERVER);
adr.port = Defines.PORT_SERVER;
Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info "
+ Defines.PROTOCOL_VERSION);
}
// send a packet to each address book entry
for (i = 0; i < 16; i++) {
//Com_sprintf (name, sizeof(name), "adr%i", i);
name = "adr" + i;
adrstring = Cvar.VariableString(name);
if (adrstring == null || adrstring.length() == 0)
continue;
log.info("pinging {} ...", adrstring);
if (!NET.StringToAdr(adrstring, adr)) {
log.warn("Bad address: {}", adrstring);
continue;
} }
if (adr.port == 0)
// we use no IPX
noipx = Cvar.Get("noipx", "1", Defines.CVAR_NOSET);
if (noipx.value == 0.0f) {
adr.type = Defines.NA_BROADCAST_IPX;
//adr.port = BigShort(PORT_SERVER); //adr.port = BigShort(PORT_SERVER);
adr.port = Defines.PORT_SERVER; adr.port = Defines.PORT_SERVER;
Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info " Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info "
+ Defines.PROTOCOL_VERSION); + Defines.PROTOCOL_VERSION);
}
// send a packet to each address book entry
for (i = 0; i < 16; i++) {
//Com_sprintf (name, sizeof(name), "adr%i", i);
name = "adr" + i;
adrstring = Cvar.VariableString(name);
if (adrstring == null || adrstring.length() == 0)
continue;
log.info("pinging {} ...", adrstring);
if (!NET.StringToAdr(adrstring, adr)) {
log.warn("Bad address: {}", adrstring);
continue;
}
if (adr.port == 0)
//adr.port = BigShort(PORT_SERVER);
adr.port = Defines.PORT_SERVER;
Netchan.OutOfBandPrint(Defines.NS_CLIENT, adr, "info "
+ Defines.PROTOCOL_VERSION);
}
} }
}; };
@@ -500,29 +476,25 @@ public final class CL {
* *
* Load or download any custom player skins and models. * Load or download any custom player skins and models.
*/ */
static Runnable Skins_f = new Runnable() { static Runnable Skins_f = () -> {
public void run() { int i;
int i;
for (i = 0; i < Defines.MAX_CLIENTS; i++) { for (i = 0; i < Defines.MAX_CLIENTS; i++) {
if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i] == null) if (Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i] == null)
continue; continue;
log.info("client {}: {}", i, Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i]); log.info("client {}: {}", i, Globals.cl.configstrings[Defines.CS_PLAYERSKINS + i]);
SCR.UpdateScreen(); SCR.UpdateScreen();
Sys.SendKeyEvents(); // pump message loop Sys.SendKeyEvents(); // pump message loop
CL_parse.ParseClientinfo(i); CL_parse.ParseClientinfo(i);
}
} }
}; };
/** /**
* Userinfo_f * Userinfo_f
*/ */
static Runnable Userinfo_f = new Runnable() { static Runnable Userinfo_f = () -> {
public void run() { log.info("User info settings:");
log.info("User info settings:"); Info.Print(Cvar.Userinfo());
Info.Print(Cvar.Userinfo());
}
}; };
/** /**
@@ -531,12 +503,10 @@ public final class CL {
* Restart the sound subsystem so it can pick up new parameters and flush * Restart the sound subsystem so it can pick up new parameters and flush
* all sounds. * all sounds.
*/ */
static Runnable Snd_Restart_f = new Runnable() { static Runnable Snd_Restart_f = () -> {
public void run() { S.Shutdown();
S.Shutdown(); S.Init();
S.Init(); CL_parse.RegisterSounds();
CL_parse.RegisterSounds();
}
}; };
// ENV_CNT is map load, ENV_CNT+1 is first env map // ENV_CNT is map load, ENV_CNT+1 is first env map
@@ -551,28 +521,26 @@ public final class CL {
* The server will send this command right before allowing the client into * The server will send this command right before allowing the client into
* the server. * the server.
*/ */
static Runnable Precache_f = new Runnable() { static Runnable Precache_f = () -> {
public void run() { // Yet another hack to let old demos work the old precache sequence.
// Yet another hack to let old demos work the old precache sequence. if (Cmd.Argc() < 2) {
if (Cmd.Argc() < 2) {
int iw[] = { 0 }; // for detecting cheater maps int iw[] = { 0 }; // for detecting cheater maps
CM.CM_LoadMap(Globals.cl.configstrings[Defines.CS_MODELS + 1], CM.CM_LoadMap(Globals.cl.configstrings[Defines.CS_MODELS + 1],
true, iw); true, iw);
CL_parse.RegisterSounds(); CL_parse.RegisterSounds();
CL_view.PrepRefresh(); CL_view.PrepRefresh();
return; return;
}
CL.precache_check = Defines.CS_MODELS;
CL.precache_spawncount = Lib.atoi(Cmd.Argv(1));
CL.precache_model = null;
CL.precache_model_skin = 0;
RequestNextDownload();
} }
CL.precache_check = Defines.CS_MODELS;
CL.precache_spawncount = Lib.atoi(Cmd.Argv(1));
CL.precache_model = null;
CL.precache_model_skin = 0;
RequestNextDownload();
}; };
private static int extratime; private static int extratime;

View File

@@ -486,167 +486,38 @@ public class CL_input {
* ============ CL_InitInput ============ * ============ CL_InitInput ============
*/ */
static void InitInput() { static void InitInput() {
Cmd.AddCommand("centerview", new Runnable() { Cmd.AddCommand("centerview", IN::CenterView);
public void run() { Cmd.AddCommand("+moveup", CL_input::IN_UpDown);
IN.CenterView(); Cmd.AddCommand("-moveup", CL_input::IN_UpUp);
} Cmd.AddCommand("+movedown", CL_input::IN_DownDown);
}); Cmd.AddCommand("-movedown", CL_input::IN_DownUp);
Cmd.AddCommand("+left", CL_input::IN_LeftDown);
Cmd.AddCommand("+moveup", new Runnable() { Cmd.AddCommand("-left", CL_input::IN_LeftUp);
public void run() { Cmd.AddCommand("+right", CL_input::IN_RightDown);
IN_UpDown(); Cmd.AddCommand("-right", CL_input::IN_RightUp);
} Cmd.AddCommand("+forward", CL_input::IN_ForwardDown);
}); Cmd.AddCommand("-forward", CL_input::IN_ForwardUp);
Cmd.AddCommand("-moveup", new Runnable() { Cmd.AddCommand("+back", CL_input::IN_BackDown);
public void run() { Cmd.AddCommand("-back", CL_input::IN_BackUp);
IN_UpUp(); Cmd.AddCommand("+lookup", CL_input::IN_LookupDown);
} Cmd.AddCommand("-lookup", CL_input::IN_LookupUp);
}); Cmd.AddCommand("+lookdown", CL_input::IN_LookdownDown);
Cmd.AddCommand("+movedown", new Runnable() { Cmd.AddCommand("-lookdown", CL_input::IN_LookdownUp);
public void run() { Cmd.AddCommand("+strafe", CL_input::IN_StrafeDown);
IN_DownDown(); Cmd.AddCommand("-strafe", CL_input::IN_StrafeUp);
} Cmd.AddCommand("+moveleft", CL_input::IN_MoveleftDown);
}); Cmd.AddCommand("-moveleft", CL_input::IN_MoveleftUp);
Cmd.AddCommand("-movedown", new Runnable() { Cmd.AddCommand("+moveright", CL_input::IN_MoverightDown);
public void run() { Cmd.AddCommand("-moveright", CL_input::IN_MoverightUp);
IN_DownUp(); Cmd.AddCommand("+speed", CL_input::IN_SpeedDown);
} Cmd.AddCommand("-speed", CL_input::IN_SpeedUp);
}); Cmd.AddCommand("+attack", CL_input::IN_AttackDown);
Cmd.AddCommand("+left", new Runnable() { Cmd.AddCommand("-attack", CL_input::IN_AttackUp);
public void run() { Cmd.AddCommand("+use", CL_input::IN_UseDown);
IN_LeftDown(); Cmd.AddCommand("-use", CL_input::IN_UseUp);
} Cmd.AddCommand("impulse", CL_input::IN_Impulse);
}); Cmd.AddCommand("+klook", CL_input::IN_KLookDown);
Cmd.AddCommand("-left", new Runnable() { Cmd.AddCommand("-klook", CL_input::IN_KLookUp);
public void run() {
IN_LeftUp();
}
});
Cmd.AddCommand("+right", new Runnable() {
public void run() {
IN_RightDown();
}
});
Cmd.AddCommand("-right", new Runnable() {
public void run() {
IN_RightUp();
}
});
Cmd.AddCommand("+forward", new Runnable() {
public void run() {
IN_ForwardDown();
}
});
Cmd.AddCommand("-forward", new Runnable() {
public void run() {
IN_ForwardUp();
}
});
Cmd.AddCommand("+back", new Runnable() {
public void run() {
IN_BackDown();
}
});
Cmd.AddCommand("-back", new Runnable() {
public void run() {
IN_BackUp();
}
});
Cmd.AddCommand("+lookup", new Runnable() {
public void run() {
IN_LookupDown();
}
});
Cmd.AddCommand("-lookup", new Runnable() {
public void run() {
IN_LookupUp();
}
});
Cmd.AddCommand("+lookdown", new Runnable() {
public void run() {
IN_LookdownDown();
}
});
Cmd.AddCommand("-lookdown", new Runnable() {
public void run() {
IN_LookdownUp();
}
});
Cmd.AddCommand("+strafe", new Runnable() {
public void run() {
IN_StrafeDown();
}
});
Cmd.AddCommand("-strafe", new Runnable() {
public void run() {
IN_StrafeUp();
}
});
Cmd.AddCommand("+moveleft", new Runnable() {
public void run() {
IN_MoveleftDown();
}
});
Cmd.AddCommand("-moveleft", new Runnable() {
public void run() {
IN_MoveleftUp();
}
});
Cmd.AddCommand("+moveright", new Runnable() {
public void run() {
IN_MoverightDown();
}
});
Cmd.AddCommand("-moveright", new Runnable() {
public void run() {
IN_MoverightUp();
}
});
Cmd.AddCommand("+speed", new Runnable() {
public void run() {
IN_SpeedDown();
}
});
Cmd.AddCommand("-speed", new Runnable() {
public void run() {
IN_SpeedUp();
}
});
Cmd.AddCommand("+attack", new Runnable() {
public void run() {
IN_AttackDown();
}
});
Cmd.AddCommand("-attack", new Runnable() {
public void run() {
IN_AttackUp();
}
});
Cmd.AddCommand("+use", new Runnable() {
public void run() {
IN_UseDown();
}
});
Cmd.AddCommand("-use", new Runnable() {
public void run() {
IN_UseUp();
}
});
Cmd.AddCommand("impulse", new Runnable() {
public void run() {
IN_Impulse();
}
});
Cmd.AddCommand("+klook", new Runnable() {
public void run() {
IN_KLookDown();
}
});
Cmd.AddCommand("-klook", new Runnable() {
public void run() {
IN_KLookUp();
}
});
cl_nodelta = Cvar.Get("cl_nodelta", "0", 0); cl_nodelta = Cvar.Get("cl_nodelta", "0", 0);
} }

View File

@@ -134,44 +134,42 @@ public class CL_parse {
* *
* Request a download from the server =============== * Request a download from the server ===============
*/ */
public static Runnable Download_f = new Runnable() { public static Runnable Download_f = () -> {
public void run() { String filename;
String filename;
if (Cmd.Argc() != 2) { if (Cmd.Argc() != 2) {
Com.Printf("Usage: download <filename>\n"); Com.Printf("Usage: download <filename>\n");
return; return;
}
filename = Cmd.Argv(1);
if (filename.indexOf("..") != -1) {
Com.Printf("Refusing to download a path with ..\n");
return;
}
if (fileSystem.loadFile(filename) != null) { // it exists, no need to
// download
Com.Printf("File already exists.\n");
return;
}
Globals.cls.downloadname = filename;
Com.Printf("Downloading " + Globals.cls.downloadname + "\n");
// download to a temp name, and only rename
// to the real name when done, so if interrupted
// a runt file wont be left
Globals.cls.downloadtempname = Com
.StripExtension(Globals.cls.downloadname);
Globals.cls.downloadtempname += ".tmp";
MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd);
MSG.WriteString(Globals.cls.netchan.message, "download "
+ Globals.cls.downloadname);
Globals.cls.downloadnumber++;
} }
filename = Cmd.Argv(1);
if (filename.indexOf("..") != -1) {
Com.Printf("Refusing to download a path with ..\n");
return;
}
if (fileSystem.loadFile(filename) != null) { // it exists, no need to
// download
Com.Printf("File already exists.\n");
return;
}
Globals.cls.downloadname = filename;
Com.Printf("Downloading " + Globals.cls.downloadname + "\n");
// download to a temp name, and only rename
// to the real name when done, so if interrupted
// a runt file wont be left
Globals.cls.downloadtempname = Com
.StripExtension(Globals.cls.downloadname);
Globals.cls.downloadtempname += ".tmp";
MSG.WriteByte(Globals.cls.netchan.message, Defines.clc_stringcmd);
MSG.WriteString(Globals.cls.netchan.message, "download "
+ Globals.cls.downloadname);
Globals.cls.downloadnumber++;
}; };
/* /*

View File

@@ -40,107 +40,99 @@ import java.util.Arrays;
@Slf4j @Slf4j
public final class Console extends Globals { public final class Console extends Globals {
private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance();
public static Runnable ToggleConsole_f = new Runnable() { public static Runnable ToggleConsole_f = () -> {
public void run() { SCR.EndLoadingPlaque(); // get rid of loading plaque
SCR.EndLoadingPlaque(); // get rid of loading plaque
if (Globals.cl.attractloop) { if (Globals.cl.attractloop) {
Cbuf.AddText("killserver\n"); Cbuf.AddText("killserver\n");
return; return;
} }
if (Globals.cls.state == Defines.ca_disconnected) { if (Globals.cls.state == Defines.ca_disconnected) {
// start the demo loop again // start the demo loop again
Cbuf.AddText("d1\n"); Cbuf.AddText("d1\n");
return; return;
} }
Key.ClearTyping(); Key.ClearTyping();
Console.ClearNotify(); Console.ClearNotify();
if (Globals.cls.key_dest == Defines.key_console) { if (Globals.cls.key_dest == Defines.key_console) {
Menu.ForceMenuOff(); Menu.ForceMenuOff();
Cvar.Set("paused", "0"); Cvar.Set("paused", "0");
} else { } else {
Menu.ForceMenuOff(); Menu.ForceMenuOff();
Globals.cls.key_dest = Defines.key_console; Globals.cls.key_dest = Defines.key_console;
if (Cvar.VariableValue("maxclients") == 1 if (Cvar.VariableValue("maxclients") == 1
&& Globals.server_state != 0) && Globals.server_state != 0)
Cvar.Set("paused", "1"); Cvar.Set("paused", "1");
}
} }
}; };
public static Runnable Clear_f = new Runnable() { public static Runnable Clear_f = () -> Arrays.fill(Globals.con.text, (byte) ' ');
public void run() {
Arrays.fill(Globals.con.text, (byte) ' '); public static Runnable Dump_f = () -> {
int l, x;
int line;
RandomAccessFile f;
byte[] buffer = new byte[1024];
String name;
if (Cmd.Argc() != 2) {
log.info("usage: condump <filename>");
return;
} }
};
public static Runnable Dump_f = new Runnable() { //Com_sprintf (name, sizeof(name), "%s/%s.txt", FS_Gamedir(),
public void run() { // Cmd_Argv(1));
name = fileSystem.getGamedir() + "/" + Cmd.Argv(1) + ".txt";
int l, x; log.info("Dumped console text to {}", name);
int line; fileSystem.createPath(name);
RandomAccessFile f; f = Lib.fopen(name, "rw");
byte[] buffer = new byte[1024]; if (f == null) {
String name; log.error("ERROR: couldn't open.");
return;
}
if (Cmd.Argc() != 2) { // skip empty lines
log.info("usage: condump <filename>"); for (l = con.current - con.totallines + 1; l <= con.current; l++) {
line = (l % con.totallines) * con.linewidth;
for (x = 0; x < con.linewidth; x++)
if (con.text[line + x] != ' ')
break;
if (x != con.linewidth)
break;
}
return; // write the remaining lines
} buffer[con.linewidth] = 0;
for (; l <= con.current; l++) {
//Com_sprintf (name, sizeof(name), "%s/%s.txt", FS_Gamedir(), line = (l % con.totallines) * con.linewidth;
// Cmd_Argv(1)); //strncpy (buffer, line, con.linewidth);
name = fileSystem.getGamedir() + "/" + Cmd.Argv(1) + ".txt"; System.arraycopy(con.text, line, buffer, 0, con.linewidth);
for (x = con.linewidth - 1; x >= 0; x--) {
log.info("Dumped console text to {}", name); if (buffer[x] == ' ')
fileSystem.createPath(name); buffer[x] = 0;
f = Lib.fopen(name, "rw"); else
if (f == null) {
log.error("ERROR: couldn't open.");
return;
}
// skip empty lines
for (l = con.current - con.totallines + 1; l <= con.current; l++) {
line = (l % con.totallines) * con.linewidth;
for (x = 0; x < con.linewidth; x++)
if (con.text[line + x] != ' ')
break;
if (x != con.linewidth)
break; break;
} }
for (x = 0; buffer[x] != 0; x++)
buffer[x] &= 0x7f;
// write the remaining lines buffer[x] = '\n';
buffer[con.linewidth] = 0; // fprintf (f, "%s\n", buffer);
for (; l <= con.current; l++) { try {
line = (l % con.totallines) * con.linewidth; f.write(buffer, 0, x + 1);
//strncpy (buffer, line, con.linewidth); } catch (IOException e) {
System.arraycopy(con.text, line, buffer, 0, con.linewidth);
for (x = con.linewidth - 1; x >= 0; x--) {
if (buffer[x] == ' ')
buffer[x] = 0;
else
break;
}
for (x = 0; buffer[x] != 0; x++)
buffer[x] &= 0x7f;
buffer[x] = '\n';
// fprintf (f, "%s\n", buffer);
try {
f.write(buffer, 0, x + 1);
} catch (IOException e) {
}
} }
Lib.fclose(f);
} }
Lib.fclose(f);
}; };
/** /**
@@ -245,40 +237,34 @@ public final class Console extends Globals {
/* /*
* ================ Con_ToggleChat_f ================ * ================ Con_ToggleChat_f ================
*/ */
static Runnable ToggleChat_f = new Runnable() { static Runnable ToggleChat_f = () -> {
public void run() { Key.ClearTyping();
Key.ClearTyping();
if (cls.key_dest == key_console) { if (cls.key_dest == key_console) {
if (cls.state == ca_active) { if (cls.state == ca_active) {
Menu.ForceMenuOff(); Menu.ForceMenuOff();
cls.key_dest = key_game; cls.key_dest = key_game;
} }
} else } else
cls.key_dest = key_console; cls.key_dest = key_console;
ClearNotify(); ClearNotify();
}
}; };
/* /*
* ================ Con_MessageMode_f ================ * ================ Con_MessageMode_f ================
*/ */
static Runnable MessageMode_f = new Runnable() { static Runnable MessageMode_f = () -> {
public void run() { chat_team = false;
chat_team = false; cls.key_dest = key_message;
cls.key_dest = key_message;
}
}; };
/* /*
* ================ Con_MessageMode2_f ================ * ================ Con_MessageMode2_f ================
*/ */
static Runnable MessageMode2_f = new Runnable() { static Runnable MessageMode2_f = () -> {
public void run() { chat_team = true;
chat_team = true; cls.key_dest = key_message;
cls.key_dest = key_message;
}
}; };
/* /*

View File

@@ -715,11 +715,7 @@ public class Key extends Globals {
return; return;
} }
public static Runnable Bind_f = new Runnable() { public static Runnable Bind_f = Key::Key_Bind_f;
public void run() {
Key_Bind_f();
}
};
static void Key_Bind_f() { static void Key_Bind_f() {
int c = Cmd.Argc(); int c = Cmd.Argc();
@@ -763,11 +759,7 @@ public class Key extends Globals {
Globals.keybindings[keynum] = binding; Globals.keybindings[keynum] = binding;
} }
static Runnable Unbind_f = new Runnable() { static Runnable Unbind_f = Key::Key_Unbind_f;
public void run() {
Key_Unbind_f();
}
};
static void Key_Unbind_f() { static void Key_Unbind_f() {
@@ -785,22 +777,14 @@ public class Key extends Globals {
Key.SetBinding(b, null); Key.SetBinding(b, null);
} }
static Runnable Unbindall_f = new Runnable() { static Runnable Unbindall_f = Key::Key_Unbindall_f;
public void run() {
Key_Unbindall_f();
}
};
static void Key_Unbindall_f() { static void Key_Unbindall_f() {
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)
Key.SetBinding(i, null); Key.SetBinding(i, null);
} }
static Runnable Bindlist_f = new Runnable() { static Runnable Bindlist_f = Key::Key_Bindlist_f;
public void run() {
Key_Bindlist_f();
}
};
static void Key_Bindlist_f() { static void Key_Bindlist_f() {
for (int i = 0; i < 256; i++) for (int i = 0; i < 256; i++)

View File

@@ -439,11 +439,7 @@ public final class Menu extends Key {
*/ */
static final int MAIN_ITEMS = 5; static final int MAIN_ITEMS = 5;
static Runnable Main_Draw = new Runnable() { static Runnable Main_Draw = Menu::Main_Draw;
public void run() {
Main_Draw();
}
};
static void Main_Draw() { static void Main_Draw() {
int i; int i;
@@ -544,18 +540,10 @@ public final class Menu extends Key {
return null; return null;
} }
static Runnable Menu_Main = new Runnable() { static Runnable Menu_Main = Menu::Menu_Main_f;
public void run() {
Menu_Main_f();
}
};
static void Menu_Main_f() { static void Menu_Main_f() {
PushMenu(new Runnable() { PushMenu(Menu::Main_Draw, new keyfunc_t() {
public void run() {
Main_Draw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return Main_Key(key); return Main_Key(key);
} }
@@ -646,19 +634,11 @@ public final class Menu extends Key {
return Default_MenuKey(s_multiplayer_menu, key); return Default_MenuKey(s_multiplayer_menu, key);
} }
static Runnable Menu_Multiplayer = new Runnable() { static Runnable Menu_Multiplayer = Menu::Menu_Multiplayer_f;
public void run() {
Menu_Multiplayer_f();
}
};
static void Menu_Multiplayer_f() { static void Menu_Multiplayer_f() {
Multiplayer_MenuInit(); Multiplayer_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::Multiplayer_MenuDraw, new keyfunc_t() {
public void run() {
Multiplayer_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return Multiplayer_MenuKey(key); return Multiplayer_MenuKey(key);
} }
@@ -1158,11 +1138,7 @@ public final class Menu extends Key {
Menu_Center(s_keys_menu); Menu_Center(s_keys_menu);
} }
static Runnable Keys_MenuDraw = new Runnable() { static Runnable Keys_MenuDraw = Menu::Keys_MenuDraw_f;
public void run() {
Keys_MenuDraw_f();
}
};
static void Keys_MenuDraw_f() { static void Keys_MenuDraw_f() {
Menu_AdjustCursor(s_keys_menu, 1); Menu_AdjustCursor(s_keys_menu, 1);
@@ -1211,19 +1187,11 @@ public final class Menu extends Key {
} }
} }
static Runnable Menu_Keys = new Runnable() { static Runnable Menu_Keys = Menu::Menu_Keys_f;
public void run() {
Menu_Keys_f();
}
};
static void Menu_Keys_f() { static void Menu_Keys_f() {
Keys_MenuInit(); Keys_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::Keys_MenuDraw_f, new keyfunc_t() {
public void run() {
Keys_MenuDraw_f();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return Keys_MenuKey_f(key); return Keys_MenuKey_f(key);
} }
@@ -1654,19 +1622,11 @@ public final class Menu extends Key {
return Default_MenuKey(s_options_menu, key); return Default_MenuKey(s_options_menu, key);
} }
static Runnable Menu_Options = new Runnable() { static Runnable Menu_Options = Menu::Menu_Options_f;
public void run() {
Menu_Options_f();
}
};
static void Menu_Options_f() { static void Menu_Options_f() {
Options_MenuInit(); Options_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::Options_MenuDraw, new keyfunc_t() {
public void run() {
Options_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return Options_MenuKey(key); return Options_MenuKey(key);
} }
@@ -1681,19 +1641,11 @@ public final class Menu extends Key {
* ======================================================================= * =======================================================================
*/ */
static Runnable Menu_Video = new Runnable() { static Runnable Menu_Video = Menu::Menu_Video_f;
public void run() {
Menu_Video_f();
}
};
static void Menu_Video_f() { static void Menu_Video_f() {
VID.MenuInit(); VID.MenuInit();
PushMenu(new Runnable() { PushMenu(VID::MenuDraw, new keyfunc_t() {
public void run() {
VID.MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return VID.MenuKey(key); return VID.MenuKey(key);
} }
@@ -1898,11 +1850,7 @@ public final class Menu extends Key {
} }
static Runnable Menu_Credits = new Runnable() { static Runnable Menu_Credits = Menu::Menu_Credits_f;
public void run() {
Menu_Credits_f();
}
};
static void Menu_Credits_f() { static void Menu_Credits_f() {
int n; int n;
@@ -1934,11 +1882,7 @@ public final class Menu extends Key {
} }
credits_start_time = cls.realtime; credits_start_time = cls.realtime;
PushMenu(new Runnable() { PushMenu(Menu::Credits_MenuDraw, new keyfunc_t() {
public void run() {
Credits_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return Credits_Key(key); return Credits_Key(key);
} }
@@ -2109,19 +2053,11 @@ public final class Menu extends Key {
return Default_MenuKey(s_game_menu, key); return Default_MenuKey(s_game_menu, key);
} }
static Runnable Menu_Game = new Runnable() { static Runnable Menu_Game = Menu::Menu_Game_f;
public void run() {
Menu_Game_f();
}
};
static void Menu_Game_f() { static void Menu_Game_f() {
Game_MenuInit(); Game_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::Game_MenuDraw, new keyfunc_t() {
public void run() {
Game_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return Game_MenuKey(key); return Game_MenuKey(key);
} }
@@ -2239,19 +2175,11 @@ public final class Menu extends Key {
return Default_MenuKey(s_loadgame_menu, key); return Default_MenuKey(s_loadgame_menu, key);
} }
static Runnable Menu_LoadGame = new Runnable() { static Runnable Menu_LoadGame = Menu::Menu_LoadGame_f;
public void run() {
Menu_LoadGame_f();
}
};
static void Menu_LoadGame_f() { static void Menu_LoadGame_f() {
LoadGame_MenuInit(); LoadGame_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::LoadGame_MenuDraw, new keyfunc_t() {
public void run() {
LoadGame_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return LoadGame_MenuKey(key); return LoadGame_MenuKey(key);
} }
@@ -2325,22 +2253,14 @@ public final class Menu extends Key {
return Default_MenuKey(s_savegame_menu, key); return Default_MenuKey(s_savegame_menu, key);
} }
static Runnable Menu_SaveGame = new Runnable() { static Runnable Menu_SaveGame = Menu::Menu_SaveGame_f;
public void run() {
Menu_SaveGame_f();
}
};
static void Menu_SaveGame_f() { static void Menu_SaveGame_f() {
if (0 == Globals.server_state) if (0 == Globals.server_state)
return; // not playing a game return; // not playing a game
SaveGame_MenuInit(); SaveGame_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::SaveGame_MenuDraw, new keyfunc_t() {
public void run() {
SaveGame_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return SaveGame_MenuKey(key); return SaveGame_MenuKey(key);
} }
@@ -2521,19 +2441,11 @@ public final class Menu extends Key {
return Default_MenuKey(s_joinserver_menu, key); return Default_MenuKey(s_joinserver_menu, key);
} }
static Runnable Menu_JoinServer = new Runnable() { static Runnable Menu_JoinServer = Menu::Menu_JoinServer_f;
public void run() {
Menu_JoinServer_f();
}
};
static void Menu_JoinServer_f() { static void Menu_JoinServer_f() {
JoinServer_MenuInit(); JoinServer_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::JoinServer_MenuDraw, new keyfunc_t() {
public void run() {
JoinServer_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return JoinServer_MenuKey(key); return JoinServer_MenuKey(key);
} }
@@ -2906,17 +2818,9 @@ public final class Menu extends Key {
return Default_MenuKey(s_startserver_menu, key); return Default_MenuKey(s_startserver_menu, key);
} }
static Runnable Menu_StartServer = new Runnable() { static Runnable Menu_StartServer = Menu::Menu_StartServer_f;
public void run() {
Menu_StartServer_f();
}
};
static Runnable startServer_MenuDraw = new Runnable() { static Runnable startServer_MenuDraw = Menu::StartServer_MenuDraw;
public void run() {
StartServer_MenuDraw();
}
};
static keyfunc_t startServer_MenuKey = new keyfunc_t() { static keyfunc_t startServer_MenuKey = new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return StartServer_MenuKey(key); return StartServer_MenuKey(key);
@@ -3380,19 +3284,11 @@ public final class Menu extends Key {
return Default_MenuKey(s_dmoptions_menu, key); return Default_MenuKey(s_dmoptions_menu, key);
} }
static Runnable Menu_DMOptions = new Runnable() { static Runnable Menu_DMOptions = Menu::Menu_DMOptions_f;
public void run() {
Menu_DMOptions_f();
}
};
static void Menu_DMOptions_f() { static void Menu_DMOptions_f() {
DMOptions_MenuInit(); DMOptions_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::DMOptions_MenuDraw, new keyfunc_t() {
public void run() {
DMOptions_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return DMOptions_MenuKey(key); return DMOptions_MenuKey(key);
} }
@@ -3545,19 +3441,11 @@ public final class Menu extends Key {
return Default_MenuKey(s_downloadoptions_menu, key); return Default_MenuKey(s_downloadoptions_menu, key);
} }
static Runnable Menu_DownloadOptions = new Runnable() { static Runnable Menu_DownloadOptions = Menu::Menu_DownloadOptions_f;
public void run() {
Menu_DownloadOptions_f();
}
};
static void Menu_DownloadOptions_f() { static void Menu_DownloadOptions_f() {
DownloadOptions_MenuInit(); DownloadOptions_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::DownloadOptions_MenuDraw, new keyfunc_t() {
public void run() {
DownloadOptions_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return DownloadOptions_MenuKey(key); return DownloadOptions_MenuKey(key);
} }
@@ -3620,30 +3508,18 @@ public final class Menu extends Key {
return Default_MenuKey(s_addressbook_menu, key); return Default_MenuKey(s_addressbook_menu, key);
} }
static Runnable AddressBook_MenuDraw = new Runnable() { static Runnable AddressBook_MenuDraw = Menu::AddressBook_MenuDraw_f;
public void run() {
AddressBook_MenuDraw_f();
}
};
static void AddressBook_MenuDraw_f() { static void AddressBook_MenuDraw_f() {
Banner("m_banner_addressbook"); Banner("m_banner_addressbook");
Menu_Draw(s_addressbook_menu); Menu_Draw(s_addressbook_menu);
} }
static Runnable Menu_AddressBook = new Runnable() { static Runnable Menu_AddressBook = Menu::Menu_AddressBook_f;
public void run() {
Menu_AddressBook_f();
}
};
static void Menu_AddressBook_f() { static void Menu_AddressBook_f() {
AddressBook_MenuInit(); AddressBook_MenuInit();
PushMenu(new Runnable() { PushMenu(Menu::AddressBook_MenuDraw_f, new keyfunc_t() {
public void run() {
AddressBook_MenuDraw_f();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return AddressBook_MenuKey_f(key); return AddressBook_MenuKey_f(key);
} }
@@ -4181,11 +4057,7 @@ public final class Menu extends Key {
return Default_MenuKey(s_player_config_menu, key); return Default_MenuKey(s_player_config_menu, key);
} }
static Runnable Menu_PlayerConfig = new Runnable() { static Runnable Menu_PlayerConfig = Menu::Menu_PlayerConfig_f;
public void run() {
Menu_PlayerConfig_f();
}
};
static void Menu_PlayerConfig_f() { static void Menu_PlayerConfig_f() {
if (!PlayerConfig_MenuInit()) { if (!PlayerConfig_MenuInit()) {
@@ -4194,11 +4066,7 @@ public final class Menu extends Key {
return; return;
} }
Menu_SetStatusBar(s_multiplayer_menu, null); Menu_SetStatusBar(s_multiplayer_menu, null);
PushMenu(new Runnable() { PushMenu(Menu::PlayerConfig_MenuDraw, new keyfunc_t() {
public void run() {
PlayerConfig_MenuDraw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return PlayerConfig_MenuKey(key); return PlayerConfig_MenuKey(key);
} }
@@ -4244,18 +4112,10 @@ public final class Menu extends Key {
re.DrawPic((viddef.width - w) / 2, (viddef.height - h) / 2, "quit"); re.DrawPic((viddef.width - w) / 2, (viddef.height - h) / 2, "quit");
} }
static Runnable Menu_Quit = new Runnable() { static Runnable Menu_Quit = Menu::Menu_Quit_f;
public void run() {
Menu_Quit_f();
}
};
static void Menu_Quit_f() { static void Menu_Quit_f() {
PushMenu(new Runnable() { PushMenu(Menu::Quit_Draw, new keyfunc_t() {
public void run() {
Quit_Draw();
}
}, new keyfunc_t() {
public String execute(int key) { public String execute(int key) {
return Quit_Key(key); return Quit_Key(key);
} }

View File

@@ -432,31 +432,11 @@ public final class SCR extends Globals {
// //
// register our commands // register our commands
// //
Cmd.AddCommand("timerefresh", new Runnable() { Cmd.AddCommand("timerefresh", SCR::TimeRefresh_f);
public void run() { Cmd.AddCommand("loading", SCR::Loading_f);
TimeRefresh_f(); Cmd.AddCommand("sizeup", SCR::SizeUp_f);
} Cmd.AddCommand("sizedown", SCR::SizeDown_f);
}); Cmd.AddCommand("sky", SCR::Sky_f);
Cmd.AddCommand("loading", new Runnable() {
public void run() {
Loading_f();
}
});
Cmd.AddCommand("sizeup", new Runnable() {
public void run() {
SizeUp_f();
}
});
Cmd.AddCommand("sizedown", new Runnable() {
public void run() {
SizeDown_f();
}
});
Cmd.AddCommand("sky", new Runnable() {
public void run() {
Sky_f();
}
});
scr_initialized = true; scr_initialized = true;
} }
@@ -1295,11 +1275,7 @@ public final class SCR extends Globals {
crosshair_pic); crosshair_pic);
} }
private static Runnable updateScreenCallback = new Runnable() { private static Runnable updateScreenCallback = SCR::UpdateScreen2;
public void run() {
UpdateScreen2();
}
};
// wird anstelle von der richtigen UpdateScreen benoetigt // wird anstelle von der richtigen UpdateScreen benoetigt
public static void UpdateScreen() { public static void UpdateScreen() {

View File

@@ -234,31 +234,25 @@ public final class V extends Globals {
} }
} }
static Runnable Gun_Next_f = new Runnable() { static Runnable Gun_Next_f = () -> {
public void run() { gun_frame++;
gun_frame++; Com.Printf("frame " + gun_frame + "\n");
Com.Printf("frame " + gun_frame + "\n");
}
}; };
static Runnable Gun_Prev_f = new Runnable() { static Runnable Gun_Prev_f = () -> {
public void run() { gun_frame--;
gun_frame--; if (gun_frame < 0)
if (gun_frame < 0) gun_frame = 0;
gun_frame = 0; Com.Printf("frame " + gun_frame + "\n");
Com.Printf("frame " + gun_frame + "\n");
}
}; };
static Runnable Gun_Model_f = new Runnable() { static Runnable Gun_Model_f = () -> {
public void run() { if (Cmd.Argc() != 2) {
if (Cmd.Argc() != 2) { gun_model = null;
gun_model = null; return;
return;
}
String name = "models/" + Cmd.Argv(1) + "/tris.md2";
gun_model = re.RegisterModel(name);
} }
String name = "models/" + Cmd.Argv(1) + "/tris.md2";
gun_model = re.RegisterModel(name);
}; };
/* /*
@@ -377,16 +371,12 @@ public final class V extends Globals {
/* /*
* ============= V_Viewpos_f ============= * ============= V_Viewpos_f =============
*/ */
static Runnable Viewpos_f = new Runnable() { static Runnable Viewpos_f = () -> log.info("({} {} {}) : {}",
public void run() { (int) cl.refdef.vieworg[0],
log.info("({} {} {}) : {}", (int) cl.refdef.vieworg[1],
(int) cl.refdef.vieworg[0], (int) cl.refdef.vieworg[2],
(int) cl.refdef.vieworg[1], (int) cl.refdef.viewangles[YAW]
(int) cl.refdef.vieworg[2], );
(int) cl.refdef.viewangles[YAW]
);
}
};
public static void Init() { public static void Init() {
Cmd.AddCommand("gun_next", Gun_Next_f); Cmd.AddCommand("gun_next", Gun_Next_f);

View File

@@ -317,11 +317,7 @@ public class VID extends Globals {
vid_modes[11].height = (int)vid_height.value; vid_modes[11].height = (int)vid_height.value;
/* Add some console commands that we want to handle */ /* Add some console commands that we want to handle */
Cmd.AddCommand ("vid_restart", new Runnable() { Cmd.AddCommand ("vid_restart", VID::Restart_f);
public void run() {
Restart_f();
}
});
/* Disable the 3Dfx splash screen */ /* Disable the 3Dfx splash screen */
// putenv("FX_GLIDE_NO_SPLASH=0"); // putenv("FX_GLIDE_NO_SPLASH=0");

View File

@@ -36,100 +36,88 @@ import java.util.Vector;
@Slf4j @Slf4j
public final class Cmd { public final class Cmd {
private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance(); private static final FileSystem fileSystem = BaseQ2FileSystem.getInstance();
static Runnable List_f = new Runnable() { static Runnable List_f = () -> {
public void run() { cmd_function_t cmd = Cmd.cmd_functions;
cmd_function_t cmd = Cmd.cmd_functions; int i = 0;
int i = 0;
while (cmd != null) { while (cmd != null) {
log.info(cmd.name); log.info(cmd.name);
i++; i++;
cmd = cmd.next; cmd = cmd.next;
}
log.info("{} commands", i);
} }
log.info("{} commands", i);
}; };
static Runnable Exec_f = new Runnable() { static Runnable Exec_f = () -> {
public void run() { if (Cmd.Argc() != 2) {
if (Cmd.Argc() != 2) { log.info("exec <filename> : execute a script file");
log.info("exec <filename> : execute a script file"); return;
return;
}
byte[] f = null;
f = fileSystem.loadFile(Cmd.Argv(1));
if (f == null) {
log.info("couldn't exec {}", Cmd.Argv(1));
return;
}
log.info("execing {}", Cmd.Argv(1));
Cbuf.InsertText(new String(f));
} }
byte[] f = null;
f = fileSystem.loadFile(Cmd.Argv(1));
if (f == null) {
log.info("couldn't exec {}", Cmd.Argv(1));
return;
}
log.info("execing {}", Cmd.Argv(1));
Cbuf.InsertText(new String(f));
}; };
static Runnable Echo_f = new Runnable() { static Runnable Echo_f = () -> {
public void run() { StringBuilder sb = new StringBuilder(Cmd.Argc());
StringBuilder sb = new StringBuilder(Cmd.Argc()); for (int i = 1; i < Cmd.Argc(); i++) {
for (int i = 1; i < Cmd.Argc(); i++) { sb.append(Cmd.Argv(i)).append(' ');
sb.append(Cmd.Argv(i)).append(' ');
}
log.info(sb.toString());
} }
log.info(sb.toString());
}; };
static Runnable Alias_f = new Runnable() { static Runnable Alias_f = () -> {
public void run() { cmdalias_t a = null;
cmdalias_t a = null; if (Cmd.Argc() == 1) {
if (Cmd.Argc() == 1) { log.info("Current alias commands:");
log.info("Current alias commands:");
for (a = Globals.cmd_alias; a != null; a = a.next) {
log.info("{} : {}", a.name, a.value);
}
return;
}
String s = Cmd.Argv(1);
if (s.length() > Defines.MAX_ALIAS_NAME) {
log.warn("Alias name is too long");
return;
}
// if the alias already exists, reuse it
for (a = Globals.cmd_alias; a != null; a = a.next) { for (a = Globals.cmd_alias; a != null; a = a.next) {
if (s.equalsIgnoreCase(a.name)) { log.info("{} : {}", a.name, a.value);
a.value = null;
break;
}
} }
return;
if (a == null) {
a = new cmdalias_t();
a.next = Globals.cmd_alias;
Globals.cmd_alias = a;
}
a.name = s;
// copy the rest of the command line
String cmd = "";
int c = Cmd.Argc();
for (int i = 2; i < c; i++) {
cmd = cmd + Cmd.Argv(i);
if (i != (c - 1))
cmd = cmd + " ";
}
cmd = cmd + "\n";
a.value = cmd;
} }
String s = Cmd.Argv(1);
if (s.length() > Defines.MAX_ALIAS_NAME) {
log.warn("Alias name is too long");
return;
}
// if the alias already exists, reuse it
for (a = Globals.cmd_alias; a != null; a = a.next) {
if (s.equalsIgnoreCase(a.name)) {
a.value = null;
break;
}
}
if (a == null) {
a = new cmdalias_t();
a.next = Globals.cmd_alias;
Globals.cmd_alias = a;
}
a.name = s;
// copy the rest of the command line
String cmd = "";
int c = Cmd.Argc();
for (int i = 2; i < c; i++) {
cmd = cmd + Cmd.Argv(i);
if (i != (c - 1))
cmd = cmd + " ";
}
cmd = cmd + "\n";
a.value = cmd;
}; };
public static Runnable Wait_f = new Runnable() { public static Runnable Wait_f = () -> Globals.cmd_wait = true;
public void run() {
Globals.cmd_wait = true;
}
};
public static cmd_function_t cmd_functions = null; public static cmd_function_t cmd_functions = null;
@@ -157,18 +145,15 @@ public final class Cmd {
private static char temporary[] = new char[Defines.MAX_STRING_CHARS]; private static char temporary[] = new char[Defines.MAX_STRING_CHARS];
public static Comparator<Integer> PlayerSort = new Comparator<Integer>() { public static Comparator<Integer> PlayerSort = (o1, o2) -> {
public int compare(Integer o1, Integer o2) { int anum1 = GameBase.game.clients[o1].ps.stats[Defines.STAT_FRAGS];
int bnum1 = GameBase.game.clients[o2].ps.stats[Defines.STAT_FRAGS];
int anum1 = GameBase.game.clients[o1].ps.stats[Defines.STAT_FRAGS];
int bnum1 = GameBase.game.clients[o2].ps.stats[Defines.STAT_FRAGS]; if (anum1 < bnum1)
return -1;
if (anum1 < bnum1) if (anum1 > bnum1)
return -1; return 1;
if (anum1 > bnum1) return 0;
return 1;
return 0;
}
}; };
/** /**

View File

@@ -238,13 +238,7 @@ public final class Com {
return new String(com_token, 0, len); return new String(com_token, 0, len);
} }
public static Runnable Error_f= new Runnable() public static Runnable Error_f= () -> Error(Defines.ERR_FATAL, Cmd.Argv(1));
{
public void run() throws IllegalStateException
{
Error(Defines.ERR_FATAL, Cmd.Argv(1));
}
};
public static void Error(int code, String fmt) throws IllegalStateException public static void Error(int code, String fmt) throws IllegalStateException
{ {

View File

@@ -229,66 +229,61 @@ public class Cvar extends Globals {
* Set command, sets variables. * Set command, sets variables.
*/ */
static Runnable Set_f = new Runnable() { static Runnable Set_f = () -> {
public void run() { int c;
int c; int flags;
int flags;
c = Cmd.Argc(); c = Cmd.Argc();
if (c != 3 && c != 4) { if (c != 3 && c != 4) {
Com.Printf("usage: set <variable> <value> [u / s]\n"); Com.Printf("usage: set <variable> <value> [u / s]\n");
return;
}
if (c == 4) {
if (Cmd.Argv(3).equals("u"))
flags = CVAR_USERINFO;
else if (Cmd.Argv(3).equals("s"))
flags = CVAR_SERVERINFO;
else {
Com.Printf("flags can only be 'u' or 's'\n");
return; return;
} }
Cvar.FullSet(Cmd.Argv(1), Cmd.Argv(2), flags);
if (c == 4) { } else
if (Cmd.Argv(3).equals("u")) Cvar.Set(Cmd.Argv(1), Cmd.Argv(2));
flags = CVAR_USERINFO;
else if (Cmd.Argv(3).equals("s"))
flags = CVAR_SERVERINFO;
else {
Com.Printf("flags can only be 'u' or 's'\n");
return;
}
Cvar.FullSet(Cmd.Argv(1), Cmd.Argv(2), flags);
} else
Cvar.Set(Cmd.Argv(1), Cmd.Argv(2));
}
}; };
/** /**
* List command, lists all available commands. * List command, lists all available commands.
*/ */
static Runnable List_f = new Runnable() { static Runnable List_f = () -> {
public void run() { cvar_t var;
cvar_t var; int i;
int i;
i = 0; i = 0;
for (var = Globals.cvar_vars; var != null; var = var.next, i++) { for (var = Globals.cvar_vars; var != null; var = var.next, i++) {
if ((var.flags & CVAR_ARCHIVE) != 0) if ((var.flags & CVAR_ARCHIVE) != 0)
Com.Printf("*"); Com.Printf("*");
else else
Com.Printf(" "); Com.Printf(" ");
if ((var.flags & CVAR_USERINFO) != 0) if ((var.flags & CVAR_USERINFO) != 0)
Com.Printf("U"); Com.Printf("U");
else else
Com.Printf(" "); Com.Printf(" ");
if ((var.flags & CVAR_SERVERINFO) != 0) if ((var.flags & CVAR_SERVERINFO) != 0)
Com.Printf("S"); Com.Printf("S");
else else
Com.Printf(" "); Com.Printf(" ");
if ((var.flags & CVAR_NOSET) != 0) if ((var.flags & CVAR_NOSET) != 0)
Com.Printf("-"); Com.Printf("-");
else if ((var.flags & CVAR_LATCH) != 0) else if ((var.flags & CVAR_LATCH) != 0)
Com.Printf("L"); Com.Printf("L");
else else
Com.Printf(" "); Com.Printf(" ");
Com.Printf(" " + var.name + " \"" + var.string + "\"\n"); Com.Printf(" " + var.name + " \"" + var.string + "\"\n");
}
Com.Printf(i + " cvars\n");
} }
Com.Printf(i + " cvars\n");
}; };

View File

@@ -995,27 +995,11 @@ public abstract class Main extends Base {
vid_gamma = Cvar.Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE); vid_gamma = Cvar.Get("vid_gamma", "1.0", Globals.CVAR_ARCHIVE);
vid_ref = Cvar.Get("vid_ref", "lwjgl", Globals.CVAR_ARCHIVE); vid_ref = Cvar.Get("vid_ref", "lwjgl", Globals.CVAR_ARCHIVE);
Cmd.AddCommand("imagelist", new Runnable() { Cmd.AddCommand("imagelist", this::GL_ImageList_f);
public void run() {
GL_ImageList_f();
}
});
Cmd.AddCommand("screenshot", new Runnable() { Cmd.AddCommand("screenshot", this::GL_ScreenShot_f);
public void run() { Cmd.AddCommand("modellist", this::Mod_Modellist_f);
GL_ScreenShot_f(); Cmd.AddCommand("gl_strings", this::GL_Strings_f);
}
});
Cmd.AddCommand("modellist", new Runnable() {
public void run() {
Mod_Modellist_f();
}
});
Cmd.AddCommand("gl_strings", new Runnable() {
public void run() {
GL_Strings_f();
}
});
} }
/** /**

View File

@@ -1027,92 +1027,28 @@ public class SV_CCMDS {
================== ==================
*/ */
public static void SV_InitOperatorCommands() { public static void SV_InitOperatorCommands() {
Cmd.AddCommand("heartbeat", new Runnable() { Cmd.AddCommand("heartbeat", SV_CCMDS::SV_Heartbeat_f);
public void run() { Cmd.AddCommand("kick", SV_CCMDS::SV_Kick_f);
SV_Heartbeat_f(); Cmd.AddCommand("status", SV_CCMDS::SV_Status_f);
} Cmd.AddCommand("serverinfo", SV_CCMDS::SV_Serverinfo_f);
}); Cmd.AddCommand("dumpuser", SV_CCMDS::SV_DumpUser_f);
Cmd.AddCommand("kick", new Runnable() {
public void run() {
SV_Kick_f();
}
});
Cmd.AddCommand("status", new Runnable() {
public void run() {
SV_Status_f();
}
});
Cmd.AddCommand("serverinfo", new Runnable() {
public void run() {
SV_Serverinfo_f();
}
});
Cmd.AddCommand("dumpuser", new Runnable() {
public void run() {
SV_DumpUser_f();
}
});
Cmd.AddCommand("map", new Runnable() { Cmd.AddCommand("map", SV_CCMDS::SV_Map_f);
public void run() { Cmd.AddCommand("demomap", SV_CCMDS::SV_DemoMap_f);
SV_Map_f(); Cmd.AddCommand("gamemap", SV_CCMDS::SV_GameMap_f);
} Cmd.AddCommand("setmaster", SV_CCMDS::SV_SetMaster_f);
});
Cmd.AddCommand("demomap", new Runnable() {
public void run() {
SV_DemoMap_f();
}
});
Cmd.AddCommand("gamemap", new Runnable() {
public void run() {
SV_GameMap_f();
}
});
Cmd.AddCommand("setmaster", new Runnable() {
public void run() {
SV_SetMaster_f();
}
});
if (Globals.dedicated.value != 0) if (Globals.dedicated.value != 0)
Cmd.AddCommand("say", new Runnable() { Cmd.AddCommand("say", SV_CCMDS::SV_ConSay_f);
public void run() {
SV_ConSay_f();
}
});
Cmd.AddCommand("serverrecord", new Runnable() { Cmd.AddCommand("serverrecord", SV_CCMDS::SV_ServerRecord_f);
public void run() { Cmd.AddCommand("serverstop", SV_CCMDS::SV_ServerStop_f);
SV_ServerRecord_f();
}
});
Cmd.AddCommand("serverstop", new Runnable() {
public void run() {
SV_ServerStop_f();
}
});
Cmd.AddCommand("save", new Runnable() { Cmd.AddCommand("save", SV_CCMDS::SV_Savegame_f);
public void run() { Cmd.AddCommand("load", SV_CCMDS::SV_Loadgame_f);
SV_Savegame_f();
}
});
Cmd.AddCommand("load", new Runnable() {
public void run() {
SV_Loadgame_f();
}
});
Cmd.AddCommand("killserver", new Runnable() { Cmd.AddCommand("killserver", SV_CCMDS::SV_KillServer_f);
public void run() {
SV_KillServer_f();
}
});
Cmd.AddCommand("sv", new Runnable() { Cmd.AddCommand("sv", SV_CCMDS::SV_ServerCommand_f);
public void run() {
SV_ServerCommand_f();
}
});
} }
} }

View File

@@ -48,54 +48,22 @@ public class SV_USER {
Runnable r; Runnable r;
} }
static ucmd_t u1 = new ucmd_t("new", new Runnable() { static ucmd_t u1 = new ucmd_t("new", SV_USER::SV_New_f);
public void run() {
SV_USER.SV_New_f();
}
});
static ucmd_t ucmds[] = { static ucmd_t ucmds[] = {
// auto issued // auto issued
new ucmd_t("new", new Runnable() { new ucmd_t("new", SV_USER::SV_New_f),
public void run() { new ucmd_t("configstrings", SV_USER::SV_Configstrings_f),
SV_USER.SV_New_f(); new ucmd_t("baselines", SV_USER::SV_Baselines_f),
} new ucmd_t("begin", SV_USER::SV_Begin_f),
}), new ucmd_t("configstrings", new Runnable() { new ucmd_t("nextserver", SV_USER::SV_Nextserver_f),
public void run() { new ucmd_t("disconnect", SV_USER::SV_Disconnect_f),
SV_USER.SV_Configstrings_f();
}
}), new ucmd_t("baselines", new Runnable() {
public void run() {
SV_USER.SV_Baselines_f();
}
}), new ucmd_t("begin", new Runnable() {
public void run() {
SV_USER.SV_Begin_f();
}
}), new ucmd_t("nextserver", new Runnable() {
public void run() {
SV_USER.SV_Nextserver_f();
}
}), new ucmd_t("disconnect", new Runnable() {
public void run() {
SV_USER.SV_Disconnect_f();
}
}),
// issued by hand at client consoles // issued by hand at client consoles
new ucmd_t("info", new Runnable() { new ucmd_t("info", SV_USER::SV_ShowServerinfo_f),
public void run() { new ucmd_t("download", SV_USER::SV_BeginDownload_f),
SV_USER.SV_ShowServerinfo_f(); new ucmd_t("nextdl", SV_USER::SV_NextDownload_f)
} };
}), new ucmd_t("download", new Runnable() {
public void run() {
SV_USER.SV_BeginDownload_f();
}
}), new ucmd_t("nextdl", new Runnable() {
public void run() {
SV_USER.SV_NextDownload_f();
}
}) };
public static final int MAX_STRINGCMDS = 8; public static final int MAX_STRINGCMDS = 8;

View File

@@ -97,26 +97,10 @@ public final class LWJGLSoundImpl implements Sound {
int count = Channel.init(buffers); int count = Channel.init(buffers);
log.info("... using {} channels", count); log.info("... using {} channels", count);
AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED); AL10.alDistanceModel(AL10.AL_INVERSE_DISTANCE_CLAMPED);
Cmd.AddCommand("play", new Runnable() { Cmd.AddCommand("play", this::Play);
public void run() { Cmd.AddCommand("stopsound", this::StopAllSounds);
Play(); Cmd.AddCommand("soundlist", this::SoundList);
} Cmd.AddCommand("soundinfo", this::SoundInfo_f);
});
Cmd.AddCommand("stopsound", new Runnable() {
public void run() {
StopAllSounds();
}
});
Cmd.AddCommand("soundlist", new Runnable() {
public void run() {
SoundList();
}
});
Cmd.AddCommand("soundinfo", new Runnable() {
public void run() {
SoundInfo_f();
}
});
num_sfx = 0; num_sfx = 0;

View File

@@ -105,28 +105,12 @@ public final class IN extends Globals {
Globals.m_forward = Cvar.Get("m_forward", "1", 0); Globals.m_forward = Cvar.Get("m_forward", "1", 0);
Globals.m_side = Cvar.Get("m_side", "0.8", 0); Globals.m_side = Cvar.Get("m_side", "0.8", 0);
Cmd.AddCommand("+mlook", new Runnable() { Cmd.AddCommand("+mlook", IN::MLookDown);
public void run() { Cmd.AddCommand("-mlook", IN::MLookUp);
MLookDown();
}
});
Cmd.AddCommand("-mlook", new Runnable() {
public void run() {
MLookUp();
}
});
Cmd.AddCommand("force_centerview", new Runnable() { Cmd.AddCommand("force_centerview", IN::Force_CenterView_f);
public void run() {
Force_CenterView_f();
}
});
Cmd.AddCommand("togglemouse", new Runnable() { Cmd.AddCommand("togglemouse", IN::toggleMouse);
public void run() {
toggleMouse();
}
});
IN.mouse_avail = true; IN.mouse_avail = true;
} }