Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 |
// ==================================================================== // Class: xVoting.MapVoteHistory_INI // // Used to save map stats/history data to an ini file. Subclasses // // Written by Bruce Bickar // (c) 2002, Epic Games, Inc. All Rights Reserved // ==================================================================== class MapVoteHistory_INI extends MapVoteHistory DependsOn(VotingHandler) Config(MapVoteHistory) PerObjectConfig; var config array<VotingHandler.MapHistoryInfo> H; // array used to store map data var config int LastMapIndex; var bool bUpdated; //------------------------------------------------------------------------------------------------ function AddMap(VotingHandler.MapHistoryInfo MapInfo) { local int x; if(MapInfo.M == "") return; bUpdated = true; if(LastMapIndex == -1) // brand new list { H.Insert(0,1); H[0].M = MapInfo.M; // add new map H[0].P = 0; H[0].S = 0; H[0].G = MapInfo.G; H[0].U = MapInfo.U; LastMapIndex = 0; return; } // search list for map for(x=0; x<=LastMapIndex; x++) { if(MapInfo.M ~= H[x].M) // found map { H[x].G = MapInfo.G; H[x].U = MapInfo.U; return; } if(Caps(H[x].M) > Caps(MapInfo.M)) // MapName is not in array and should be inserted here { H.Insert(x,1); LastMapIndex++; H[x].M = MapInfo.M; H[x].P = 0; H[x].S = 0; H[x].G = MapInfo.G; H[x].U = MapInfo.U; return; } } // didnt find insertion point so add at end LastMapIndex++; H.Insert(LastMapIndex,1); H[LastMapIndex].M = MapInfo.M; H[LastMapIndex].P = 0; H[LastMapIndex].S = 0; H[LastMapIndex].G = MapInfo.G; H[LastMapIndex].U = MapInfo.U; return; } //------------------------------------------------------------------------------------------------ function VotingHandler.MapHistoryInfo PlayMap(string MapName) { local int x,y; local bool bFound; local VotingHandler.MapHistoryInfo MapInfo; if(MapName == "") return MapInfo; bUpdated = true; if(LastMapIndex > H.Length - 1) LastMapIndex = H.Length - 1; if(LastMapIndex == -1) // brand new list { H.Insert(0,1); H[0].M = MapName; // add new map H[0].P = 1; H[0].S = 1; H[0].G = ""; H[0].U = ""; LastMapIndex = 0; MapInfo = H[0]; return MapInfo; } bFound = false; for(x=0; x<=LastMapIndex; x++) { if(MapName ~= H[x].M) // found map { H[x].S=1; // Set sequence (last 1 map played) H[x].P++; // increment Play count MapInfo = H[x]; // save data to return to caller bFound=true; } else { if(H[x].S > 0) // -1 indicates not to every play this map, 0 is a map that has never been played H[x].S++; // increment the sequence of all maps to make room for # 1 } if(Caps(H[x].M) > Caps(MapName) && !bFound) // MapName is not in array and should be inserted here { H.Insert(x,1); LastMapIndex++; for(y=LastMapIndex; y>x; y--) { if(H[y].S > 0) H[y].S++; } H[x].M = MapName; // add new map H[x].P = 1; H[x].S = 1; H[x].G = ""; H[x].U = ""; MapInfo = H[x]; return MapInfo; } } if(!bFound) // didnt find insertion point so add at end { LastMapIndex++; H.Insert(LastMapIndex,1); H[LastMapIndex].M = MapName; H[LastMapIndex].P = 1; H[LastMapIndex].S = 1; H[LastMapIndex].G = ""; H[LastMapIndex].U = ""; MapInfo = H[LastMapIndex]; } return MapInfo; } //------------------------------------------------------------------------------------------------ function VotingHandler.MapHistoryInfo GetMapHistory(string MapName) { local int Index; local VotingHandler.MapHistoryInfo MapInfo; Index = FindIndex(MapName); if(Index > -1 && Index < H.Length) { MapInfo = H[Index]; } return MapInfo; } //------------------------------------------------------------------------------------------------ function Save() { if(bUpdated) SaveConfig(); bUpdated = false; } //------------------------------------------------------------------------------------------------ function RemoveOldestMap() { local int x,Lowest; bUpdated = true; // scan the list for the oldest played map Lowest = 1; for(x=2; x<=LastMapIndex; x++) { if(H[x].S < H[Lowest].S) Lowest = x; } RemoveMapByIndex(Lowest); } //------------------------------------------------------------------------------------------------ function RemoveMap(string MapName) { local int Index; bUpdated = true; Index = FindIndex(MapName); if(Index > 0) RemoveMapByIndex(Index); } //------------------------------------------------------------------------------------------------ function RemoveMapByIndex(int Index) { bUpdated = true; H.Remove(Index,1); LastMapIndex--; } //------------------------------------------------------------------------------------------------ function int FindIndex(string MapName) { local int a,b,i; // speedy way to find the map if it alread exists //a 7 b //12345678901234568901234567890123456789012345 //|----------|----------|----------|----------| //1 < too high //2---------------------b b = ((b - a)/2) + a //3 > too low //4 a----------b a = ((b - a)/2) + a //7 < too high //8 a----b b = ((b - a)/2) + a //9 > too low //10 a--b a = ((b - a)/2) + a //11 > too low //12 a-b //13 > too low //14 ab //15 > too low //16 b a==b if(LastMapIndex == -1) return(-1); a = 1; b = LastMapIndex+1; while(true) { i = ((b-a)/2)+a; if(H[i-1].M ~= MapName) // check for a match return(i-1); // found if(a == b) // Not found return(-1); if(Caps(H[i-1].M) > Caps(MapName)) //check mid-way b = i; // too high else { if(a == i) a = b; else a = i; // too low } } } //------------------------------------------------------------------------------------------------ function Swap(int a,int b) { local VotingHandler.MapHistoryInfo MapInfo; MapInfo = H[a]; H[a] = H[b]; H[b] = MapInfo; } //------------------------------------------------------------------------------------------------ defaultproperties { LastMapIndex=-1 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |