📄 zigserver_8h-source.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>zigserver.h Source File</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.2.18 --><center><a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center><hr><h1>zigserver.h</h1><a href="zigserver_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <span class="comment">/*</span>00002 <span class="comment"> ZIG - An extendable, portable game engine focused on networking & scripting</span>00003 <span class="comment"> Project Home: http://zige.sourceforge.net</span>00004 <span class="comment"> Copyright (C) 2002 F醔io Reis Cecin <fcecin AT inf DOT ufrgs DOT br></span>00005 <span class="comment"></span>00006 <span class="comment"> This library is free software; you can redistribute it and/or</span>00007 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>00008 <span class="comment"> License as published by the Free Software Foundation; either</span>00009 <span class="comment"> version 2.1 of the License, or (at your option) any later version.</span>00010 <span class="comment"></span>00011 <span class="comment"> This library is distributed in the hope that it will be useful,</span>00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>00014 <span class="comment"> Lesser General Public License for more details.</span>00015 <span class="comment"></span>00016 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>00017 <span class="comment"> License along with this library; if not, write to the Free Software</span>00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA </span>00019 <span class="comment">*/</span>00020 <span class="comment">/*</span>00021 <span class="comment"></span>00022 <span class="comment"> zigserver</span>00023 <span class="comment"></span>00024 <span class="comment"> ZIG Game Engine Skeleton </span>00025 <span class="comment"> server class</span>00026 <span class="comment"></span>00027 <span class="comment">*/</span>00028 00029 <span class="preprocessor">#ifndef _ZIG_HEADER_ZIGSERVER_H_</span>00030 <span class="preprocessor"></span><span class="preprocessor">#define _ZIG_HEADER_ZIGSERVER_H_</span>00031 <span class="preprocessor"></span>00032 <span class="comment">//some internal #define switches to control the implementation</span>00033 <span class="preprocessor">#include "zigdefs.h"</span>00034 00035 <span class="comment">//if defined in zigdefs.h...</span>00036 <span class="preprocessor">#ifdef ZIG_SERIALIZE_CALLBACKS</span>00037 <span class="preprocessor"></span><span class="preprocessor">#define ZIGSERVER_SERIALIZE_CALLBACKS</span>00038 <span class="preprocessor"></span><span class="preprocessor">#endif</span>00039 <span class="preprocessor"></span>00040 <span class="preprocessor">#include "server.h"</span>00041 <span class="preprocessor">#include "console.h"</span>00042 <span class="preprocessor">#include "zigletman.h"</span>00043 <span class="preprocessor">#include "<a class="code" href="zig_8h.html">zig.h</a>"</span>00044 <span class="preprocessor">#include "address.h"</span>00045 00050 00051 <span class="keyword">enum</span> {00052 00054 <a class="code" href="zigserver_8h.html#a8a0">ZIGLET_NOT_FOUND</a> = 0,00055 00057 <a class="code" href="zigserver_8h.html#a8a1">ZIGLET_STATUS_NOT_REQUIRED</a>, 00058 00060 <a class="code" href="zigserver_8h.html#a8a2">ZIGLET_STATUS_RECOMMENDED</a>,00061 00063 <a class="code" href="zigserver_8h.html#a8a3">ZIGLET_STATUS_REQUIRED</a>00064 };00065 00067 <span class="keyword">enum</span> {00068 00070 <a class="code" href="zigserver_8h.html#a9a4">ZIGSERVER_DISCONNECTED</a> = 0,00071 00073 <a class="code" href="zigserver_8h.html#a9a5">ZIGSERVER_DISCONNECTED_LIMIT_CRITICALS</a>,00074 00076 <a class="code" href="zigserver_8h.html#a9a6">ZIGSERVER_DISCONNECTED_LIMIT_RELDELTA</a>,00077 00079 <a class="code" href="zigserver_8h.html#a9a7">ZIGSERVER_DISCONNECTED_LIMIT_ACKDELTA</a>00080 };00081 00082 00083 <span class="comment">//auxiliary class- ziglet selection info</span>00084 <span class="keyword">class </span>ziglet_selector_c {00085 <span class="keyword">public</span>:00086 ziglet_selector_c() { reset(); }00087 <span class="keywordtype">void</span> reset() {00088 select_level = 0;00089 select_version = <span class="stringliteral">""</span>;00090 }00091 <span class="keywordtype">int</span> select_level; <span class="comment">//selection level ("status codes" from above)</span>00092 std::string select_version; <span class="comment">//the version selected</span>00093 };00094 00095 <span class="keyword">class </span><a class="code" href="classzigserver__c.html">zigserver_c</a>;00096 00097 <span class="comment">//auxiliary class for a <client-id --- > client> class</span>00098 <span class="keyword">class </span>zig_remote_client_c {00099 <span class="keyword">public</span>:00100 zig_remote_client_c(<span class="keywordtype">int</span> client_id) { id = client_id; reset(); }00101 <span class="keywordtype">void</span> reset() {00102 <span class="keywordtype">int</span> i;<span class="keywordflow">for</span> (i=0;i<4;i++)ping_id[i]=0;00103 latency = 0;00104 ready = <span class="keyword">false</span>;00105 quit_ziglet_thread = <span class="keyword">false</span>;00106 ziglet_selectors_password = -1;00107 file_channel_id = -1;00108 file_channel_status = 0;00109 file_test_result = 0;00110 misc_threads_counter = 0;00111 misc_threads_quit = <span class="keyword">false</span>;00112 ziglet_callback_pending = <span class="keyword">false</span>;00113 }00114 00115 <span class="comment">//my ID!</span>00116 <span class="keywordtype">int</span> id;00117 00118 <span class="comment">//counter for "misc threads" for this client</span>00119 <span class="comment">//you CAN'T disconnect the client/delete this client object or remove</span>00120 <span class="comment">// the pointer from the map to this object if this counter is > 0.</span>00121 atomic_counter_c misc_threads_counter;00122 <span class="keyword">volatile</span> <span class="keywordtype">bool</span> misc_threads_quit; <span class="comment">//set to true to speed up misc threads quitting</span>00123 00124 <span class="comment">//selector password</span>00125 <span class="keywordtype">int</span> ziglet_selectors_password;00126 00127 <span class="comment">//ID of TCP channel that will be used for file transfer</span>00128 <span class="keyword">volatile</span> <span class="keywordtype">int</span> file_channel_id;00129 <span class="keyword">volatile</span> <span class="keywordtype">int</span> file_channel_status; <span class="comment">// 0=waiting 1=ok -1 failed</span>00130 <span class="keyword">volatile</span> <span class="keywordtype">int</span> file_test_result; <span class="comment">// 0=waiting 1=ok -1 failed</span>00131 00132 <span class="comment">//ping id % 4 diz qual o indice em que ele vai</span>00133 NLushort ping_id[4]; <span class="comment">// 0 se nenhum, id do ping se existente</span>00134 <span class="keywordtype">double</span> ping_time[4]; <span class="comment">// tempo do send packet</span>00135 <span class="keywordtype">int</span> latency; <span class="comment">// client's estimated latency in milliseconds</span>00136 00137 <span class="comment">//client's resource-files-on-disk-wise state</span>00138 <span class="keywordtype">bool</span> ready; <span class="comment">//true="ready" false="preparing" (downloading/checking for resource files)</span>00139 00140 <span class="comment">//a brand-spanking new thread just to negotiate ziglet updates with the client!</span>00141 <span class="comment">//created when leet_client_connected(), goes away when it's done or when the client</span>00142 <span class="comment">//is disconnected.</span>00143 thread_c<zigserver_c> ziglet_thread;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -