/* * ============== SCR_CenterPrint * * Called for important messages that should stay in the center of the * screen for a few moments ============== */ static void CenterPrint(String str) { // char *s; int s; StringBuffer line = new StringBuffer(64); int i, j, l; // strncpy (scr_centerstring, str, sizeof(scr_centerstring)-1); scr_centerstring = str; scr_centertime_off = scr_centertime.value; scr_centertime_start = cl.time; // count the number of lines for centering scr_center_lines = 1; s = 0; while (s < str.length()) { if (str.charAt(s) == '\n') scr_center_lines++; s++; } // echo it to the console Com.Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); s = 0; if (str.length() != 0) { do { // scan the width of the line for (l = 0; l < 40 && (l + s) < str.length(); l++) if (str.charAt(s + l) == '\n' || str.charAt(s + l) == 0) break; for (i = 0; i < (40 - l) / 2; i++) line.append(' '); for (j = 0; j < l; j++) { line.append(str.charAt(s + j)); } line.append('\n'); Com.Printf(line.toString()); while (s < str.length() && str.charAt(s) != '\n') s++; if (s == str.length()) break; s++; // skip the \n } while (true); } Com.Printf( "\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n\n"); Console.ClearNotify(); }
public static void DPrintf(String fmt, Vargs vargs) { if (Globals.developer == null || Globals.developer.value == 0) return; // don't confuse non-developers with techie stuff... _debugContext = debugContext; Printf(fmt, vargs); _debugContext = ""; }
public static void Error(int code, String fmt, Vargs vargs) throws LongJmpException { // va_list argptr; // static char msg[MAXPRINTMSG]; if (recursive) { Sys.Error("recursive error after: " + msg); } recursive = true; msg = sprintf(fmt, vargs); if (code == Constants.ERR_DISCONNECT) { Client.drop(); recursive = false; throw new LongJmpException(); } else if (code == Constants.ERR_DROP) { Com.Printf("********************\nERROR: " + msg + "\n********************\n"); ServerMain.SV_Shutdown("Server crashed: " + msg + "\n", false); Client.drop(); recursive = false; throw new LongJmpException(); } else { ServerMain.SV_Shutdown("Server fatal crashed: %s" + msg + "\n", false); Client.shutdown(); } Sys.Error(msg); }
/* * ================ SCR_TimeRefresh_f ================ */ static void TimeRefresh_f() { int i; int start, stop; float time; if (cls.state != ca_active) return; start = Timer.Milliseconds(); if (Commands.Argc() == 2) { // run without page flipping re.BeginFrame(0); for (i = 0; i < 128; i++) { cl.refdef.viewangles[1] = i / 128.0f * 360.0f; re.RenderFrame(cl.refdef); } re.EndFrame(); } else { for (i = 0; i < 128; i++) { cl.refdef.viewangles[1] = i / 128.0f * 360.0f; re.BeginFrame(0); re.RenderFrame(cl.refdef); re.EndFrame(); } } stop = Timer.Milliseconds(); time = (stop - start) / 1000.0f; Com.Printf("%f seconds (%f fps)\n", new Vargs(2).add(time).add(128.0f / time)); }
/* * ================= SCR_Sky_f * * Set a specific sky and rotation speed ================= */ static void Sky_f() { float rotate; float[] axis = {0, 0, 0}; if (Commands.Argc() < 2) { Com.Printf("Usage: sky <basename> <rotate> <axis x y z>\n"); return; } if (Commands.Argc() > 2) rotate = Float.parseFloat(Commands.Argv(2)); else rotate = 0; if (Commands.Argc() == 6) { axis[0] = Float.parseFloat(Commands.Argv(3)); axis[1] = Float.parseFloat(Commands.Argv(4)); axis[2] = Float.parseFloat(Commands.Argv(5)); } else { axis[0] = 0; axis[1] = 0; axis[2] = 1; } re.SetSky(Commands.Argv(1), rotate, axis); }
public static void Println(String fmt) { Printf(_debugContext + fmt + "\n"); }
public static void Printf(String fmt) { Printf(_debugContext + fmt, null); }
// See GameSpanw.ED_ParseEdict() to see how to use it now. public static String Parse(ParseHelp hlp) { int c; int len = 0; if (hlp.data == null) { return ""; } while (true) { // skip whitespace hlp.skipwhites(); if (hlp.isEof()) { hlp.data = null; return ""; } // skip // comments if (hlp.getchar() == '/') { if (hlp.nextchar() == '/') { hlp.skiptoeol(); // goto skip whitespace continue; } else { hlp.prevchar(); break; } } else break; } // handle quoted strings specially if (hlp.getchar() == '\"') { hlp.nextchar(); while (true) { c = hlp.getchar(); hlp.nextchar(); if (c == '\"' || c == 0) { return new String(com_token, 0, len); } if (len < Constants.MAX_TOKEN_CHARS) { com_token[len] = (char) c; len++; } } } // parse a regular word c = hlp.getchar(); do { if (len < Constants.MAX_TOKEN_CHARS) { com_token[len] = (char) c; len++; } c = hlp.nextchar(); } while (c > 32); if (len == Constants.MAX_TOKEN_CHARS) { Com.Printf("Token exceeded " + Constants.MAX_TOKEN_CHARS + " chars, discarded.\n"); len = 0; } return new String(com_token, 0, len); }
public static void UpdateScreen2() { int numframes; int i; // if the screen is disabled (loading plaque is up, or vid mode // changing) // do nothing at all if (cls.disable_screen != 0) { if (Timer.Milliseconds() - cls.disable_screen > 120000) { cls.disable_screen = 0; Com.Printf("Loading plaque timed out.\n"); } DrawConsole(); DrawLoading(); return; } if (!scr_initialized || !con.initialized) return; // not initialized yet /* * * range check cl_camera_separation so we don't inadvertently fry * someone's * brain */ if (cl_stereo_separation.value > 1.0) ConsoleVariables.SetValue("cl_stereo_separation", 1.0f); else if (cl_stereo_separation.value < 0) ConsoleVariables.SetValue("cl_stereo_separation", 0.0f); if (cl_stereo.value != 0) { numframes = 2; separation[0] = -cl_stereo_separation.value / 2; separation[1] = cl_stereo_separation.value / 2; } else { separation[0] = 0; separation[1] = 0; numframes = 1; } for (i = 0; i < numframes; i++) { re.BeginFrame(separation[i]); if (scr_draw_loading == 2) { // loading plaque over black screen Dimension dim = new Dimension(); re.CinematicSetPalette(null); scr_draw_loading = 0; // false re.DrawGetPicSize(dim, "loading"); re.DrawPic((viddef.width - dim.width) / 2, (viddef.height - dim.height) / 2, "loading"); } // if a cinematic is supposed to be running, handle menus // and console specially else if (cl.cinematictime > 0) { if (cls.key_dest == key_menu) { if (cl.cinematicpalette_active) { re.CinematicSetPalette(null); cl.cinematicpalette_active = false; } Menu.Draw(); } else if (cls.key_dest == key_console) { if (cl.cinematicpalette_active) { re.CinematicSetPalette(null); cl.cinematicpalette_active = false; } DrawConsole(); } else { DrawCinematic(); } } else if (ResourceLoader.Pump()) { TileClear(); DrawStats(); CheckDrawCenterString(); DrawPause(); DrawConsole(); Menu.Draw(); DrawLoading(); } else { // make sure the game palette is active if (cl.cinematicpalette_active) { re.CinematicSetPalette(null); cl.cinematicpalette_active = false; } // do 3D refresh drawing, and then update the screen CalcVrect(); // clear any dirty part of the background TileClear(); Video.RenderView(separation[i]); DrawStats(); if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 1) != 0) DrawLayout(); if ((cl.frame.playerstate.stats[STAT_LAYOUTS] & 2) != 0) ClientInventory.DrawInventory(); DrawNet(); CheckDrawCenterString(); DrawFPS(); // // if (scr_timegraph->value) // SCR_DebugGraph (cls.frametime*300, 0); // // if (scr_debuggraph->value || scr_timegraph->value || // scr_netgraph->value) // SCR_DrawDebugGraph (); // DrawPause(); DrawConsole(); Menu.Draw(); DrawLoading(); } } Globals.re.EndFrame(); }
/** * tries to send an unreliable message to a connection, and handles the transmition / * retransmition of the reliable messages. * * <p>A 0 length will still generate a packet and deal with the reliable messages. */ public static void Transmit(NetworkChannel chan, int length, byte data[]) { int send_reliable; int w1, w2; // check for message overflow if (chan.message.overflowed) { chan.fatal_error = true; Com.Printf(NET.AdrToString(chan.remote_address) + ":Outgoing message overflow\n"); return; } send_reliable = chan.Netchan_NeedReliable() ? 1 : 0; if (chan.reliable_length == 0 && chan.message.cursize != 0) { System.arraycopy(chan.message_buf, 0, chan.reliable_buf, 0, chan.message.cursize); chan.reliable_length = chan.message.cursize; chan.message.cursize = 0; chan.reliable_sequence ^= 1; } // write the packet header Buffer send = Buffer.wrap(send_buf).order(ByteOrder.LITTLE_ENDIAN); w1 = (chan.outgoing_sequence & ~(1 << 31)) | (send_reliable << 31); w2 = (chan.incoming_sequence & ~(1 << 31)) | (chan.incoming_reliable_sequence << 31); chan.outgoing_sequence++; chan.last_sent = (int) Globals.curtime; send.putInt(w1); send.putInt(w2); // send the qport if we are a client if (chan.sock == Constants.NS_CLIENT) send.WriteShort((int) consoleQport.value); // copy the reliable message to the packet first if (send_reliable != 0) { Buffers.Write(send, chan.reliable_buf, chan.reliable_length); chan.last_reliable_sequence = chan.outgoing_sequence; } // add the unreliable part if space is available if (send.maxsize - send.cursize >= length) Buffers.Write(send, data, length); else Com.Printf("Netchan_Transmit: dumped unreliable\n"); // send the datagram NET.SendPacket(chan.sock, send.cursize, send.data, chan.remote_address); if (showpackets.value != 0) { if (send_reliable != 0) Com.Printf( // "send %4i : s=%i reliable=%i ack=%i rack=%i\n" "send " + send.cursize + " : s=" + (chan.outgoing_sequence - 1) + " reliable=" + chan.reliable_sequence + " ack=" + chan.incoming_sequence + " rack=" + chan.incoming_reliable_sequence + "\n"); else Com.Printf( // "send %4i : s=%i ack=%i rack=%i\n" "send " + send.cursize + " : s=" + (chan.outgoing_sequence - 1) + " ack=" + chan.incoming_sequence + " rack=" + chan.incoming_reliable_sequence + "\n"); } }
/** * called when the current net_message is from remote_address modifies net_message so that it * points to the packet payload ================= */ public static boolean Process(NetworkChannel chan, Buffer msg) { int sequence, sequence_ack; int reliable_ack, reliable_message; int qport; // get sequence numbers msg.reset(); sequence = msg.getInt(); sequence_ack = msg.getInt(); // read the qport if we are a server if (chan.sock == Constants.NS_SERVER) qport = msg.getShort(); // achtung unsigned int reliable_message = sequence >>> 31; reliable_ack = sequence_ack >>> 31; sequence &= ~(1 << 31); sequence_ack &= ~(1 << 31); if (showpackets.value != 0) { if (reliable_message != 0) Com.Printf( // "recv %4i : s=%i reliable=%i ack=%i rack=%i\n" "recv " + msg.cursize + " : s=" + sequence + " reliable=" + (chan.incoming_reliable_sequence ^ 1) + " ack=" + sequence_ack + " rack=" + reliable_ack + "\n"); else Com.Printf( // "recv %4i : s=%i ack=%i rack=%i\n" "recv " + msg.cursize + " : s=" + sequence + " ack=" + sequence_ack + " rack=" + reliable_ack + "\n"); } // // discard stale or duplicated packets // if (sequence <= chan.incoming_sequence) { if (showdrop.value != 0) Com.Printf( NET.AdrToString(chan.remote_address) + ":Out of order packet " + sequence + " at " + chan.incoming_sequence + "\n"); return false; } // // dropped packets don't keep the message from being used // chan.dropped = sequence - (chan.incoming_sequence + 1); if (chan.dropped > 0) { if (showdrop.value != 0) Com.Printf( NET.AdrToString(chan.remote_address) + ":Dropped " + chan.dropped + " packets at " + sequence + "\n"); } // // if the current outgoing reliable message has been acknowledged // clear the buffer to make way for the next // if (reliable_ack == chan.reliable_sequence) chan.reliable_length = 0; // it has been received // // if this message contains a reliable message, bump // incoming_reliable_sequence // chan.incoming_sequence = sequence; chan.incoming_acknowledged = sequence_ack; chan.incoming_reliable_acknowledged = reliable_ack; if (reliable_message != 0) { chan.incoming_reliable_sequence ^= 1; } // // the message can now be read from the current message pointer // chan.last_received = (int) Globals.curtime; return true; }