From c06cd191a25ea4ae9117b621e6d3fb2f3139aa37 Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 14 Oct 2015 22:10:14 -0500 Subject: [PATCH] -first official stable release -fixed last known error (due to web front passing invalid sql syntax) -re-added stats. though still not working 100% -added welcome plugin --- Admin/Main.cs | 2 +- Admin/plugins/SimpleStatsPlugin.dll | Bin 12288 -> 12288 bytes Admin/plugins/WebfrontPlugin.dll | Bin 26624 -> 26624 bytes Admin/version.txt | 8 +- IW4M Admin.sln | 6 + Stats Plugin/Main.cs | 24 +-- Welcome Plugin/CountryLookup.cs | 173 ++++++++++++++++++++++ Welcome Plugin/Main.cs | 62 ++++++++ Welcome Plugin/Properties/AssemblyInfo.cs | 36 +++++ Welcome Plugin/Welcome Plugin.csproj | 57 +++++++ 10 files changed, 355 insertions(+), 13 deletions(-) create mode 100644 Welcome Plugin/CountryLookup.cs create mode 100644 Welcome Plugin/Main.cs create mode 100644 Welcome Plugin/Properties/AssemblyInfo.cs create mode 100644 Welcome Plugin/Welcome Plugin.csproj diff --git a/Admin/Main.cs b/Admin/Main.cs index a19c741ca..ec42b221e 100644 --- a/Admin/Main.cs +++ b/Admin/Main.cs @@ -15,7 +15,7 @@ namespace IW4MAdmin static void Main(string[] args) { - Version = 0.95; + Version = 1.0; double latestVersion = 0; handler = new ConsoleEventDelegate(OnProcessExit); SetConsoleCtrlHandler(handler, true); diff --git a/Admin/plugins/SimpleStatsPlugin.dll b/Admin/plugins/SimpleStatsPlugin.dll index 7594a6fe2e336d3ebf9fee439df4fb0d9b0aed89..235f29e055538630d960451dfe7fe214e5a73b80 100644 GIT binary patch delta 639 zcmZvaOK4L;6o&sZH}`1?P5RJcv=1M-i8Yo6A}S3Psuqb*nrbW*2^DOGN)>c<7fq@b zu^Zz=X?+y8E)-!vTuB!a5JgUy^s@H26rDW=6v3+u^k}u-ww4Oe!aQ&kNXTB%FDEHUuVj@LVvpGDuTkCtI#yIn zWCi8rk;vQjQK5P5fa6+#5#Hr`q*JE#WY-JAwjmEk771$o4bHylHH=!}xX>Kj1LF ztuC1jq1{_uRR^6ZbKwC;2dZ$%<^PtF0p%$J1N9~~P#^~;zJ^q6(znn#MOoHzuK%uK z&Cvna7z*hM4Ka;`RBdX7CM|8b1BbOI6B{_r_#&|4HK%a!IneNqOLMT2@>49~BbBfT z6X}4y&>3!K&z^t=aSl<;s`K%)@z(b{hL`jEt{q-GwAlLNe&2QVY3G>M&!ch5Hw)eg z?pcASz^`e%I8yAs`0M1G>B{kkce69O-1DpIv}@6AVR6%dr}9E-tMhk20C_WYSw+)7 PHL<>5#WLTiHemh%AtQB4 delta 608 zcmZojXh@jQ!F=_;1_mA=U&D=oL1wZd zlg{KwMs>z5lN%Z91t$O%gMbGRGcm9-OxP^QWX!~9HrbWs43{|*bF~Nq1D6KJWF1yB z!D2=R28aN2wGdF)cyl!?8{=dlHd$k)YE}jY7KmiN8c!+xK{L;vv!KeZBi@!RAXUC|= zz{b!6<{e}3VdP?9XLtbR1%r7{pekb+je&A{8X$egIC2;*88{hCp}bN?TOiK{%4-D6 zxqx|X5>pwtfO1Pi;M^b}cLPKz!%3hOTnslLat!ByPUB*jpb4^~jo}7kI0H9>j~0aY zkTDJzQ4-n^o)JSD10O@e=0c%lA%T+(v#y_d>j0xY45XL| zh-HAW;{uFfkeh;nU4lDKnsV7$9d?=7(QjAsRQ}lJ1Pu;Gp$>PDdI*>YVk=Bk6l0p; eK6#dA$z%scfz5ncznGaem~R%;d(Sx0fE@tnS#@v# diff --git a/Admin/plugins/WebfrontPlugin.dll b/Admin/plugins/WebfrontPlugin.dll index 9254f330624d2cec41eb9da04e0c03e45362395c..ff484a3783c8043b4376edc2ac8b6ac6071695ad 100644 GIT binary patch delta 88 zcmZp;z}RqsaY6?(lcfB{ZpUx|z5j8MYk4{ycmBKZvYkb4(&jtiTiA7gvSAEBzy!oH oj0_AbYJoVOfgvc^C3yQXMuE+ORc^Cu7X1A)MSK0`J@GCa0A9u(`~Uy| delta 88 zcmZp;z}RqsaY6_4)%%hgyB)&?cDArDDr&RwUAS+p%F+-Xm(6#=x3KE~Wy2VNfC-3Y p7#SE=)B 60) - { inactiveMinutes[E.Origin.clientID]++; - } - + killerStats.Kills++; if (killerStats.Deaths == 0) @@ -119,14 +118,17 @@ namespace StatsPlugin playerStats.updateStats(Killer, killerStats); - killStreaks[E.Origin.clientID]++; - deathStreaks[E.Origin.clientID] = 0; + killStreaks[Killer.clientID] += 1; + deathStreaks[Killer.clientID] = 0; - Killer.Tell(messageOnStreak(killStreaks[E.Origin.clientID], deathStreaks[E.Origin.clientID])); + Killer.Tell(messageOnStreak(killStreaks[Killer.clientID], deathStreaks[Killer.clientID])); } if (E.Type == Event.GType.Death) { + if (E.Origin == E.Target || E.Origin == null) + return; + Player Victim = E.Origin; PlayerStats victimStats = playerStats.getStats(Victim); @@ -135,10 +137,10 @@ namespace StatsPlugin playerStats.updateStats(Victim, victimStats); - deathStreaks[E.Origin.clientID]++; - killStreaks[E.Origin.clientID] = 0; + deathStreaks[Victim.clientID] += 1; + killStreaks[Victim.clientID] = 0; - Victim.Tell(messageOnStreak(killStreaks[E.Origin.clientID], deathStreaks[E.Origin.clientID])); + Victim.Tell(messageOnStreak(killStreaks[Victim.clientID], deathStreaks[Victim.clientID])); } } @@ -247,7 +249,7 @@ namespace StatsPlugin { get { - return 0.2f; + return 0.3f; } } diff --git a/Welcome Plugin/CountryLookup.cs b/Welcome Plugin/CountryLookup.cs new file mode 100644 index 000000000..15dddec33 --- /dev/null +++ b/Welcome Plugin/CountryLookup.cs @@ -0,0 +1,173 @@ +/* CountryLookup.cs + * + * Copyright (C) 2008 MaxMind, Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +using System; +using System.IO; +using System.Data; +using System.Net; + + +namespace CountryLookupProj +{ + /// + /// Summary description for CountryLookup. + /// + public class CountryLookup + { + private FileStream fileInput; + private static long COUNTRY_BEGIN = 16776960; + private static string[] countryCode = + { "--","AP","EU","AD","AE","AF","AG","AI","AL","AM","AN","AO","AQ","AR","AS","AT","AU","AW","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BM","BN","BO","BR","BS","BT","BV","BW","BY","BZ","CA","CC","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CU","CV","CX","CY","CZ","DE","DJ","DK","DM","DO","DZ", + "EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FM","FO","FR","FX","GA","GB","GD","GE","GF","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HM","HN","HR","HT","HU","ID","IE","IL","IN","IO","IQ","IR","IS","IT","JM","JO","JP","KE","KG","KH","KI","KM","KN","KP","KR","KW","KY","KZ", + "LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","MG","MH","MK","ML","MM","MN","MO","MP","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NF","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PW","PY","QA", + "RE","RO","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","ST","SV","SY","SZ","TC","TD","TF","TG","TH","TJ","TK","TM","TN","TO","TL","TR","TT","TV","TW","TZ","UA","UG","UM","US","UY","UZ","VA","VC","VE","VG","VI","VN","VU","WF","WS","YE","YT","RS","ZA","ZM","ME","ZW","A1","A2", + "O1","AX","GG","IM","JE","BL","MF" + }; + private static string[] countryName = + {"N/A","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles","Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados","Bangladesh","Belgium", + "Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia","Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the","Central African Republic","Congo","Switzerland","Cote D'Ivoire", + "Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica","Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic","Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji","Falkland Islands (Malvinas)", + "Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia","French Guiana","Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala","Guam","Guinea-Bissau","Guyana", + "Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia","Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan","Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis", + "Korea, Democratic People's Republic of","Korea, Republic of","Kuwait","Cayman Islands","Kazakstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania","Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of","Madagascar", + "Marshall Islands","Macedonia","Mali","Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives","Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua","Netherlands", + "Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia","Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau","Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia", + "Solomon Islands","Seychelles","Sudan","Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname","Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo", + "Thailand","Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan","Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines", + "Venezuela","Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa","Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider", + "Other","Aland Islands","Guernsey","Isle of Man","Jersey","Saint Barthelemy","Saint Martin"}; + + + public CountryLookup(string fileName) + { + try + { + fileInput = new FileStream(fileName, FileMode.Open, FileAccess.Read); + } + catch (FileNotFoundException e) + { + Console.WriteLine("File " + fileName + " not found."); + } + } + + public string lookupCountryCode(string str) + { + IPAddress addr; + try + { + addr = IPAddress.Parse(str); + } + catch (FormatException e) + { + return "--"; + } + return lookupCountryCode(addr); + } + + private long addrToNum(IPAddress addr) + { + long ipnum = 0; + byte[] b = BitConverter.GetBytes(addr.Address); + for (int i = 0; i < 4; ++i) + { + long y = b[i]; + if (y < 0) + { + y += 256; + } + ipnum += y << ((3 - i) * 8); + } + //Console.WriteLine(ipnum); + return ipnum; + } + + public string lookupCountryCode(IPAddress addr) + { + return (countryCode[(int)seekCountry(0, addrToNum(addr), 31)]); + } + + public string lookupCountryName(string str) + { + IPAddress addr; + try + { + addr = IPAddress.Parse(str); + } + catch (FormatException e) + { + return "N/A"; + } + return lookupCountryName(addr); + } + + public string lookupCountryName(IPAddress addr) + { + return (countryName[(int)seekCountry(0, addrToNum(addr), 31)]); + } + + private long seekCountry(long offset, long ipnum, int depth) + { + byte[] buf = new byte[6]; + long[] x = new long[2]; + if (depth == 0) + { + Console.WriteLine("Error seeking country."); + } + try + { + fileInput.Seek(6 * offset, 0); + fileInput.Read(buf, 0, 6); + } + catch (IOException e) + { + Console.WriteLine("IO Exception"); + } + for (int i = 0; i < 2; i++) + { + x[i] = 0; + for (int j = 0; j < 3; j++) + { + int y = buf[i * 3 + j]; + if (y < 0) + { + y += 256; + } + x[i] += (y << (j * 8)); + } + } + + if ((ipnum & (1 << depth)) > 0) + { + if (x[1] >= COUNTRY_BEGIN) + { + return x[1] - COUNTRY_BEGIN; + } + return seekCountry(x[1], ipnum, depth - 1); + } + else + { + if (x[0] >= COUNTRY_BEGIN) + { + return x[0] - COUNTRY_BEGIN; + } + return seekCountry(x[0], ipnum, depth - 1); + } + } + } +} diff --git a/Welcome Plugin/Main.cs b/Welcome Plugin/Main.cs new file mode 100644 index 000000000..63450c3d2 --- /dev/null +++ b/Welcome Plugin/Main.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SharedLibrary; + +namespace Welcome_Plugin +{ + public class Main : Plugin + { + public override string Author + { + get + { + return "RaidMax"; + } + } + + public override float Version + { + get + { + return 1.0f; + } + } + + public override string Name + { + get + { + return "Welcome Plugin"; + } + } + + public override void onEvent(Event E) + { + if (E.Type == Event.GType.Connect) + { + Player newPlayer = E.Origin; + + if (newPlayer.Level > Player.Permission.User) + E.Owner.Broadcast(Utilities.levelToColor(newPlayer.Level) + " ^5" + newPlayer.Name + " ^7has joined the server."); + + else + { + CountryLookupProj.CountryLookup CLT = new CountryLookupProj.CountryLookup("GeoIP.dat"); + E.Owner.Broadcast("^5" + newPlayer.Name + " ^7hails from ^5" + CLT.lookupCountryName(newPlayer.IP)); + } + } + } + + public override void onLoad() + { + return; + } + + public override void onUnload() + { + return; + } + } +} diff --git a/Welcome Plugin/Properties/AssemblyInfo.cs b/Welcome Plugin/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..60132458c --- /dev/null +++ b/Welcome Plugin/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Welcome Plugin")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Welcome Plugin")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("fd92be42-d165-449d-8648-fb1f6638b451")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Welcome Plugin/Welcome Plugin.csproj b/Welcome Plugin/Welcome Plugin.csproj new file mode 100644 index 000000000..8afb8cddc --- /dev/null +++ b/Welcome Plugin/Welcome Plugin.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {AF097E6B-48D5-4452-9CCF-0A81A21F341D} + Library + Properties + Welcome_Plugin + Welcome Plugin + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\Admin\lib\SharedLibrary.dll + + + + + + + + + + + + + + + + + \ No newline at end of file