private string GetLeaders(CTypes type) { var listNames = $" -- {configData.Messaging.MSG_ColorMain}{MSG(type.ToString().ToLower()).ToUpper()}</color>\n\n"; var userStats = new Dictionary <string, int>(); foreach (var entry in statCache) { var name = entry.Value.DisplayName; if (userStats.ContainsKey(entry.Value.DisplayName)) { name += $"({UnityEngine.Random.Range(0, 1000)})"; } userStats.Add(name, entry.Value.Stats[type]); } var leaders = userStats.OrderByDescending(a => a.Value).Take(25); int i = 1; foreach (var entry in leaders) { listNames += $"{i}. - {configData.Messaging.MSG_ColorMain}{entry.Value}</color> - {entry.Key}\n"; i++; } return(listNames); }
public override string TryInferType(CIntermediateLang cil) { switch (Op) { case OpType.Add: case OpType.Sub: case OpType.Mul: case OpType.Div: return(CTypes.BestNumberType(Lhs.TryInferType(cil), Rhs.TryInferType(cil))); case OpType.Mod: case OpType.And: case OpType.Or: case OpType.Xor: case OpType.LShift: case OpType.RShift: return(CTypes.LargerIntegerType(Lhs.TryInferType(cil), Rhs.TryInferType(cil))); case OpType.Equals: case OpType.NotEquals: case OpType.LessThan: case OpType.LessThanEquals: case OpType.GreaterThan: case OpType.GreaterThanEquals: return("int"); } throw new NotImplementedException("TODO: Exception for type inference failing."); }
public override string TryInferType(CIntermediateLang cil) { // TODO: Remove a level of pointers var ty = Pointer.TryInferType(cil); return(CTypes.DereferenceType(ty)); }
private void SwitchLeader(ulong ID, CTypes type) { if (configData.Options.UseBetterChat && BetterChat) { var name = GetGroupName(type); if (UserInGroup(titleCache[type].UserID.ToString(), name)) { RemoveFromGroup(titleCache[type].UserID.ToString(), name); } AddToGroup(ID.ToString(), name); } titleCache[type] = new LeaderData { Count = statCache[ID].Stats[type], DisplayName = statCache[ID].DisplayName, UserID = ID }; if (configData.Options.AnnounceNewLeaders) { string message = MSG("newLeader", ID.ToString()) .Replace("{playername}", $"{configData.Messaging.MSG_ColorMain}{statCache[ID].DisplayName}</color>{configData.Messaging.MSG_ColorMsg}") .Replace("{ctype}", $"</color>{configData.Messaging.MSG_ColorMain}{MSG(type.ToString().ToLower(), ID.ToString())}</color>"); PrintToChat(message); } }
public override void Codegen(CIntermediateLang cil, IndentingStringBuilder sb) { if (cil.CurrentFunction == null) { throw new NotImplementedException("TODO: Exception for return not in function"); } var funcType = cil.CurrentFunction.TryInferType(cil); if (ReturnExpression == null) { if (funcType != "void") { throw new CILTypeMismatchException(SourceInfo, funcType, "void"); } sb.LineDecl(SourceInfo); sb.AppendLine("return;"); } else { var retType = ReturnExpression.TryInferType(cil); if ((!CTypes.IsIntegerType(retType) && !CTypes.IsIntegerType(funcType)) && retType != funcType) { throw new CILTypeMismatchException(SourceInfo, funcType, retType); } ReturnExpression.Codegen(cil, sb); sb.LineDecl(SourceInfo); sb.AppendLine(string.Format("return {0};", cil.LastUsedVar)); } }
private void AddPoints(BasePlayer player, CTypes type, int amount) { if (configData.Options.IgnoreAdmins && player.IsAdmin()) { return; } CheckEntry(player); statCache[player.userID].Stats[type] += amount; CheckForUpdate(player, type); }
private void RegisterGroup(CTypes type) { var name = GetGroupName(type); if (!GroupExists(name)) { NewGroup(name); SetGroupTitle(name); SetGroupColor(name); } }
public override void Codegen(CIntermediateLang cil, IndentingStringBuilder sb) { var ty = Thing.TryInferType(cil); var separator = CTypes.IsPointerType(ty) ? "->" : "."; var @struct = cil.SymTable.LookupStruct(ty); // TODO: Handle key not found exception var member = @struct.Members[Member]; Thing.Codegen(cil, sb); var thingVar = cil.LastUsedVar; cil.LastUsedVar = string.Format("{0}{1}{2}", thingVar, separator, member.Name); }
private void CheckForUpdate(BasePlayer player, CTypes type) { if (titleCache[type].UserID == player.userID) { titleCache[type].Count = statCache[player.userID].Stats[type]; return; } if (!configData.Options.UseUpdateTimer) { if (statCache[player.userID].Stats[type] > titleCache[type].Count) { SwitchLeader(player.userID, type); } } }
public MainWindow() { InitializeComponent(); PhoneTypeComboBox.Items.Add("Business"); PhoneTypeComboBox.Items.Add("Home"); PhoneTypeComboBox.Items.Add("Mobile"); _current = 0; _curEmail = 0; _currentPhoneNumber = 0; _currentType = CTypes.All; _selectedEntries = CreateSelectedEntries(); Display(); }
public MainWindow() { InitializeComponent(); PhoneTypeComboBox.Items.Add("Business"); PhoneTypeComboBox.Items.Add("Home"); PhoneTypeComboBox.Items.Add("Mobile"); _current = 0; _curEmail = 0; _currentPhoneNumber = 0; _currentType = CTypes.All; _selectedEntries = CreateSelectedEntries(); Display(); }
private int GetCode(CTypes type, int code) { if (type == CTypes.Keyword) { code = Resource.KEYS_FROM + keywordCount; keywordCount++; } if (type == CTypes.Identifier) { code = Resource.IDENTIFIERS_FROM + identifCount; identifCount++; } if (type == CTypes.Constant) { code = Resource.CONSTANTS_FROM + constantsCount; constantsCount++; } if (type == CTypes.Delimetr) { code = Resource.DELIMITERS_FROM + delimetersCount; delimetersCount++; } return(code); }
public override string TryInferType(CIntermediateLang cil) { var ty = What.TryInferType(cil); return(CTypes.DereferenceType(ty)); }
private void rbBusiness_Checked(object sender, RoutedEventArgs e) { _currentType = CTypes.Business; RefreshContactType(); }
private string GetGroupName(CTypes type) { switch (type) { case CTypes.Animals: return(configData.Titles.AnimalsKilled); case CTypes.Arrows: return(configData.Titles.ArrowKills); case CTypes.Clothes: return(configData.Titles.ClothesCrafted); case CTypes.Headshots: return(configData.Titles.Headshots); case CTypes.Plants: return(configData.Titles.PlantsGathered); case CTypes.Healed: return(configData.Titles.PlayersHealed); case CTypes.Killed: return(configData.Titles.PlayersKilled); case CTypes.Melee: return(configData.Titles.MeleeKills); case CTypes.Revolver: return(configData.Titles.RevolverKills); case CTypes.Rockets: return(configData.Titles.RocketsFired); case CTypes.Rocks: return(configData.Titles.RocksGathered); case CTypes.Swords: return(configData.Titles.BladeKills); case CTypes.Built: return(configData.Titles.StructuresBuilt); case CTypes.Repaired: return(configData.Titles.StructuresRepaired); case CTypes.Explosives: return(configData.Titles.ThrownExplosives); case CTypes.Weapons: return(configData.Titles.WeaponsCrafted); case CTypes.Wood: return(configData.Titles.WoodGathered); case CTypes.Quests: return(configData.Titles.QuestsCompleted); case CTypes.PVPKill: return(configData.Titles.PVPKillDistance); case CTypes.PVEKill: return(configData.Titles.PVEKillDistance); default: return(null); } }
public static extern IntPtr MonitorFromPoint(CTypes.POINTSTRUCT pt, uint flags);
static void Main(string[] args) { Console.Title = "MBuild - A Marvelous Translation and Hacking Tool"; Console.WriteLine("MBuild - " + Application.ProductVersion.ToString().Split('.')[0] + "." + Application.ProductVersion.ToString().Split('.')[1]); Console.WriteLine("A Marvelous Translation and Hacking Tool"); Console.WriteLine("Written by DackR aka Daniel Martin Burgess\r\n"); if (args.Length == 0) { Console.WriteLine("No Arguments specified."); UseXML("MBuild.MBXML", !Settings.Default.AutoBuild); } else { string mArg = args[0].Trim().ToLower(); switch (mArg) { case "build": BuildXML(args); break; case "dump-script": DumpScript(args); break; case "bin-script": BuildScript(args); break; case "comp": CompressFile(args); break; case "decomp": DeCompressFile(args); break; case "bpp-convert": //BuildScript(args); break; case "dmpptr": DumpPointers(); break; case "fixsum": FixCheckSum(args); break; case "mbxml-shell": string[] makeArg = new string[] { "-f", "-t", ".mbxml", "-si", Application.ExecutablePath, "-a", Application.ExecutablePath, "-sn", "MBXML File", "-sc", "MBuild_XML_File" }; //string[] assocArg = new string[] { "-f", "-t", ".txt", "-associate", Application.ExecutablePath }; CTypes.Main(makeArg); //CTypes.Main(assocArg); //FileAssociation.SetAssociation(".mbxml", "MBuild_XML_File", Application.ExecutablePath, "MBXML File", args); break; case "ips": MakeIPS(args); break; case "xdelta": MakexDelta(args); break; case "extract": //used to extract RAW binary data from a file ExtractBin(args); break; case "dmpdata": //Dump data located at the various pointers DumpData(args); break; case "bm5dump": SBM5.DumpDataFromPointerTab(@"F:\GoogleDrive\SBM5\Base\Base.sfc", @"F:\GoogleDrive\SBM5\Dump\"); break; case "test": string romfile = @"D:\GoogleDrive\SuperFamicomWars\base.sfc"; byte[] data = File.ReadAllBytes(romfile); MemoryStream ms = LZSS.Decompress(data); byte[] dcdata = ms.ToArray(); break; default: if (mArg.ToLower().Contains(".mbxml") && File.Exists(mArg)) { //detected xml file specified... Try to build. UseXML(mArg, false); //Console.WriteLine(mArg); //Console.ReadKey(true); } break; } } LCompress.LunarCompressCleanup(); xDelta.xDeltaCleanup(); bool wait = false; Console.Write("Press any key to exit (\"q\" to stop count-down)"); DateTime beginWait = DateTime.Now; while (!Console.KeyAvailable && DateTime.Now.Subtract(beginWait).TotalSeconds < 3) { Console.Write("."); Thread.Sleep(250); } if (Console.KeyAvailable && (Console.ReadKey(true).Key == ConsoleKey.Q)) { wait = true; } if (wait) { Console.CursorLeft = 0; Console.Write(("").PadLeft(79, ' ')); Console.CursorLeft = 0; Console.Write("Press any key to exit..."); Console.ReadKey(true); } }
public void DefineWord(string word, CTypes type, int code, int col, int row) { if (temp == null) { return; } code = GetCode(type, code); var l_word = new Word(code, word, col, row); temp = null; if (type == CTypes.Keyword)//добавляем в таблицу если ключевое слово { for (int j = 0; j < Resource.reservedWords.Length; j++) { if (word == Resource.reservedWords[j]) { for (int i = 0; i < ReservedT.Count; i++) { if (word == ReservedT[i].name) { l_word.code = ReservedT[i].code; l_word.code = GetCode(CTypes.Keyword, code); goto fillcode_keyword; } } l_word.code = GetCode(CTypes.Keyword, code); ReservedT.Add(l_word); fillcode_keyword : FillCodeT(l_word); return; } else { type = CTypes.Identifier;//если слово не заресервированое то считаем его идентификаторо if (Char.IsDigit(l_word.name.First())) { var l_constant = ""; var l_identif = ""; for (var i = 0; i < l_word.name.Length; i++) { if (Char.IsDigit(l_word.name[i])) { l_constant += l_word.name[i]; } else { do { i++; l_identif += l_word.name[i]; } while (IsLetter(l_word.name[i])); break; } } var constant_word = new Word(code, l_constant, col, row); ConstantT.Add(constant_word); var identif_word = new Word(code, l_identif, col + l_constant.Length, row); IdentifierT.Add(identif_word); l_word.code = GetCode(CTypes.Constant, constant_word.code); FillCodeT(constant_word); l_word.code = GetCode(CTypes.Identifier, identif_word.code); FillCodeT(identif_word); // Console.WriteLine("[" + l_word.row + "," + l_word.col + "] '" + l_word.name + "' ERROR : Unexpected token (started from num)"); errors.Add("[" + l_word.row + "," + l_word.col + "] '" + l_word.name + "' ERROR : Unexpected token (started from num)"); return; } } } } switch (type) { case CTypes.Identifier: //добавляем идентфикаторы l_word.code = GetCode(CTypes.Identifier, code); for (int j = 0; j < IdentifierT.Count; j++) { if (word == IdentifierT[j].name) { l_word.code = IdentifierT[j].code; FillCodeT(l_word); return; } } IdentifierT.Add(l_word); FillCodeT(l_word); break; case CTypes.Delimetr: //добавляем делиметры l_word.code = GetCode(CTypes.Delimetr, code); for (int j = 0; j < DelimetrT.Count; j++) { if (word == DelimetrT[j].name) { l_word.code = DelimetrT[j].code; FillCodeT(l_word); return; } } DelimetrT.Add(l_word); FillCodeT(l_word); break; } return; }
public List <Word> Analyze(StreamReader text) { while (text.Peek() >= 0) { var cur_symbol = (char)text.Read(); start: col++; acsiiCode = (int)cur_symbol; if (cur_symbol == ' ' && temp != null) { DefineWord(temp, type, acsiiCode, col - temp.Length, row); goto start; } if (cur_symbol == '\n') { col = 0; row++; } if (IsLetterOrNum(acsiiCode))// если буква { if (temp == null) { temp += cur_symbol; type = CTypes.Keyword; } else if (type == CTypes.Keyword)//при встрече вророго раза буквы,продолжеем читать слово { temp += cur_symbol; } else if (type == CTypes.Delimetr) { DefineWord(temp, type, (int)temp[0], col - temp.Length + 1, row); temp += cur_symbol; type = CTypes.Keyword; } } // если симаол делисметров if (IsDelimetr(cur_symbol) || IsComment(temp + cur_symbol)) { if (temp == null) { temp += cur_symbol; type = CTypes.Delimetr; } else if (type == CTypes.Delimetr) { if (IsComment(temp + cur_symbol))//проверяем на возможность коментария { temp = null; // DefineWord(temp + cur_symbol, type, acsiiCode, col - temp.Length, row);//если коментарий то записываем в таблицу start_COM: do { cur_symbol = (char)text.Read(); col++; if (cur_symbol == '\uffff') { errors.Add("ERROR not closed comment"); //Console.WriteLine("ERROR not closed comment"); return(null); } } while (cur_symbol != '*');//игнорируем вунтри клментария temp += cur_symbol; cur_symbol = (char)text.Read(); col++; if (IsComment(temp + cur_symbol)) { temp = null; cur_symbol = ' '; goto start; } else { temp = null; goto start_COM; } } else { DefineWord(temp, type, acsiiCode, col - temp.Length, row); temp += cur_symbol; } } else { DefineWord(temp, type, acsiiCode, col - temp.Length, row); temp += cur_symbol; type = CTypes.Delimetr; } } if ((!IsLetterOrNum(acsiiCode)) && !IsDelimetr(cur_symbol) && temp != null)//если не буква и не делиметр { DefineWord(temp, type, acsiiCode, col - temp.Length, row); if (cur_symbol != '\r' && cur_symbol != '\n')//если символ не входит в граматику - ошибка { errors.Add(UnexpectedToken(cur_symbol, row, col)); } } } if (temp != null) { DefineWord(temp, type, acsiiCode, col - temp.Length, row); } PrintTables(); if (errors.Count > 0) { PrintErrors(); return(null); } return(CodeT); }
private void rbBusiness_Checked(object sender, RoutedEventArgs e) { _currentType = CTypes.Business; RefreshContactType(); }
private void rbFriends_Checked(object sender, RoutedEventArgs e) { _currentType = CTypes.Friend; RefreshContactType(); }
private void rbFriends_Checked(object sender, RoutedEventArgs e) { _currentType = CTypes.Friend; RefreshContactType(); }