Called once per frame for the dedicated server
| 724 | |
| 725 | // Called once per frame for the dedicated server |
| 726 | void DoDedicatedServerFrame() { |
| 727 | char str[255]; |
| 728 | char command[255] = {}; // operand |
| 729 | char operand[255]; // operand |
| 730 | |
| 731 | ListenDedicatedSocket(); |
| 732 | DedicatedReadTelnet(); |
| 733 | |
| 734 | // CallGameDLL (EVT_GAME_INTERVAL,&DLLInfo); |
| 735 | |
| 736 | if (ServerTimeout) { |
| 737 | float now = timer_GetTime(); |
| 738 | int sincelastpacket = ((float)(now - LastPacketReceived)) / 60; |
| 739 | // See if it's time to shutdown... |
| 740 | if (sincelastpacket > ServerTimeout) { |
| 741 | int quitno = DedicatedServerLex("Quit"); |
| 742 | if (quitno >= 0) |
| 743 | SetCVar(CVars[quitno].varname, "", false); |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | bool new_command = con_Input(str, 255); |
| 748 | |
| 749 | if (!new_command) |
| 750 | return; |
| 751 | |
| 752 | if (str[0] == '$') { |
| 753 | DLLInfo.input_string = str; |
| 754 | CallGameDLL(EVT_CLIENT_INPUT_STRING, &DLLInfo); |
| 755 | return; |
| 756 | } |
| 757 | |
| 758 | ParseLine(str, command, operand, 255, 255); |
| 759 | |
| 760 | if (!command[0]) |
| 761 | return; |
| 762 | |
| 763 | int index = DedicatedServerLex(command); |
| 764 | |
| 765 | if (index < 0) { |
| 766 | PrintDedicatedMessage(TXT_DS_BADCOMMAND); |
| 767 | PrintDedicatedMessage("\n"); |
| 768 | return; |
| 769 | } |
| 770 | |
| 771 | // Everything ok, set command |
| 772 | SetCVar(CVars[index].varname, operand, false); |
| 773 | } |
| 774 | |
| 775 | // Prints a message to the console if the dedicated server is active |
| 776 | void PrintDedicatedMessage(const char *fmt, ...) { |
no test coverage detected