Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Welcome to our site

Take a moment to join our board


Popular Content

Showing content with the highest reputation since 01/26/2020 in all areas

  1. 3 points
    Hungarian notation is no longer recommended in modern codebases. Outside of old C/C++ codebases or APIs (like WinAPI), it is less and less common to prefix the variables with some kind of type. Personally, I'd strongly suggest you not to get use to it (and even less to introduce it in other languages).
  2. 2 points
    Nice! I would also add that migration systems generally come with Up/Down changes. If a migration fails, I would expect the next migration to not run and all other changes be reverted. The reason being is that if I build a table called Users, then a table called Characters that has a foreign key, if Users table fails to execute properly I would expect it to revert all changes and stop all remaining changes. In this case, Characters table would fail to be created due to the foreign key. I like the idea of this as it requires raw queries over some sort of abstract migration system. If I have all of the sql written, it makes it easier if the current migration system becomes abandoned or perhaps a better one is released (I like options.)
  3. 1 point
    I usually use C++ for things like this. Lower level Windows APIs are all in C/C++, so you'll have much finer control of memory and processes on Windows from C++. For example, if you wanted to create a new process in a suspended state and then modify its memory, you could use CreateProcess with a creation flag (CREATE_SUSPENDED). You don't have that option from C# ProcessStartInfo class. You can always use C# and use PInvokes, but I don't think it's an appropriate use for the language. Plus, if you want to inject a library as well, it means you'd be using two separate languages at that point (or trying to inject the .NET runtime which is extremely painful). Those are my two cents on the topic.
  4. 1 point
    That can be achieved by editing the instruction bytes at run-time. There are two types of JE/JZ which are Near and Short jumps and the main difference is short jumps only jump a distance of a byte while near can jump a distance up to 4 bytes. You will need to identify which it is because the new bytes representing the JMP instruction will vary based on the jump distance, if the distance is a short then the new byte should be 0xEB while the near jump will be 0xE9 , keep in mind that a near JE instruction code is 2 bytes long while the near JMP code is 1 byte long so you will need to keep that in mind.
  5. 1 point
    Okay, so I'm starting World Conquer v4 with this XD * Forked
  6. 1 point
    Hello! Today I've got a few free minutes at my work and coded something that I noticed that I need long time ago! There's room for improvements of course but this will be good for those who often updates their game database and also need to keep track of the changes. The script is simple and I'll be updating here as I upgrade my code on my server. using System; using System.IO; using MySql.Data.MySqlClient; namespace FtwCore.Database.Migrations { public sealed class MigrationManager { private string m_szConnectionString; private string m_szMirationsPath; public MigrationManager(string host, string user, string pass, string data, int port) { m_szMirationsPath = Environment.CurrentDirectory + "\\migrations\\"; m_szConnectionString = $"Server={host};Port={port};Database={data};Uid={user};Password={pass};charset=utf8;"; } public string LastExcepttion { get; private set; } public void Migrate() { if (!Directory.Exists(m_szMirationsPath)) Directory.CreateDirectory(m_szMirationsPath); string[] files = Directory.GetFiles(m_szMirationsPath); foreach (var file in files) { FileInfo info = new FileInfo(file); if (info.Extension != ".sql") { Console.WriteLine([email protected]"Skip migration file {info.Name} not sql"); continue; } if (Path.GetFileNameWithoutExtension(file).Length < 16) { Console.WriteLine([email protected]"Skip migration file {info.Name} name length less than 16"); continue; } string szYear = info.Name.Substring(0, 4); string szMonth = info.Name.Substring(4, 2); string szDay = info.Name.Substring(6, 2); string szHours = info.Name.Substring(8, 2); string szMinutes = info.Name.Substring(10, 2); string szSeconds = info.Name.Substring(12, 2); if (!int.TryParse(szYear, out int year) || !int.TryParse(szMonth, out int month) || !int.TryParse(szDay, out int day) || !int.TryParse(szHours, out int hour) || !int.TryParse(szMinutes, out int minute) || !int.TryParse(szSeconds, out int second) || !DateTime.TryParse($"{year}-{month}-{day} {hour}:{minute}:{second}", out DateTime dtFullTime)) { Console.WriteLine([email protected]"Skip migration file {info.Name} invalid date stamp yyyyMMddHHmmss"); continue; } string fileName = Path.GetFileName(file); if (HasExecuted(fileName)) { continue; } if (!Execute(fileName)) { Console.WriteLine([email protected]"Error on executing migration for file {info.Name}! Error: {LastExcepttion}"); continue; } ExecuteInsert($"INSERT INTO `migrations` (`file`, `execute_time`) VALUES ('{fileName}', '{DateTime.Now:yyyy-MM-dd HH:mm:ss}')"); } } public bool Execute(string fileName) { if (!fileName.ToLower().EndsWith(".sql")) fileName += ".sql"; try { using (MySqlConnection conn = new MySqlConnection(m_szConnectionString)) { conn.Open(); MySqlScript script = new MySqlScript(conn, File.ReadAllText($"{m_szMirationsPath}{fileName}")); script.Execute(); conn.Close(); } return true; } catch (MySqlException ex) { LastExcepttion = ex.Message; return false; } } public bool HasExecuted(string fileName) { string query = "SELECT id FROM migrations WHERE `file`[email protected] LIMIT 1"; try { using (MySqlConnection conn = new MySqlConnection(m_szConnectionString)) { using (MySqlCommand command = new MySqlCommand(query, conn)) { conn.Open(); command.Prepare(); command.Parameters.AddWithValue("@file", fileName); bool result = command.ExecuteReader().HasRows; conn.Close(); return result; } } } catch (MySqlException ex) { LastExcepttion = ex.Message; return false; } } public int ExecuteInsert(string szQuery) { try { int result = -1; using (MySqlConnection conn = new MySqlConnection(m_szConnectionString)) { using (MySqlCommand command = new MySqlCommand(szQuery, conn)) { conn.Open(); result = command.ExecuteNonQuery(); conn.Close(); } } return result; } catch (MySqlException ex) { LastExcepttion = ex.Message; return -1; } } public bool TestConnection() { try { using (MySqlConnection conn = new MySqlConnection(m_szConnectionString)) { conn.Open(); conn.Close(); } return true; } catch (MySqlException ex) { LastExcepttion = ex.Message; return false; } } } } How to use: Create a 'migrations' folder on your executable path Put all your SQL Scripts in files inside of it Files must have yyyyMMddHHmmss as the first 14 characters Files must have from 16 to 128 characters Before loading your mysql data just create a new instance of the MigrationManager and call .Migrate() method Done! Then, anything that you code on your test database, save the final code on a SQL file, name it 20200129183000 WhateverYouWant.sql and put in your production migrations folder! If the code hasn't been executed, your server will execute and you can keep track of the updates. Ey! I'm sending your first migration sql file so you can test it! Good luck. PS: don't forget to change the namespace! 20200129182100_MyVeryFirstMigration.sql
  7. 1 point
    Looks good. I think someone mentioned naming conventions on the other board. Here're the naming guidelines I follow for dotnet. Outside of naming conversations, I prefer nice interfaces for parameterized queries over database ORMs. Maybe I've worked in Go for too long though. I can see a system like this doing really well for plain MySQL.
  8. 1 point
    Introduction This command-line tool allows you to edit the floor cells of Conquer Online data maps (DMaps). Each floor cell contains a flag on if players are blocked from stepping on the cell, what the surface feedback effect is when stepping on the cell, and what the elevation the cell is on. Similar to the Portal Editor, this tool can be compiled using the golang compiler for Windows, Mac, or Linux. I wrote this tool at work during our end-of-sprint game time, so it's a bit rushed. If you have any problems using it, let me know. Just fyi though, it's a command-line tool, so you must use it from a command prompt window. Picture Downloads See my portfolio website for download links and source code.
  9. 1 point
    Hi all, I realized recently that we have a few new members who don't know much about me, so I thought I'd take some time to re-introduce myself after so-many years. My real name is Gareth, but I prefer to be called "Spirited" online. I'm 27 years old, straight, male, occasionally attractive at best. I don't really post many details about myself these days, but you can find me on most platforms by the name Spirited, accompanied by a picture of a smug snow leopard. I tried to change up the snow leopard thing for Cooldown, but at the end of the day, I can appreciate a bit of familiarity. These days, I mostly work and hang out with friends. Sometimes I program in my free time, experimenting with different technologies, architectures, and project ideas. Game programming is a fun hobby of mine, but dangerously shares the same creativity / motivation pool as a lot of my other hobbies, such as photography and painting. I hope to get some inspiration through this board and the talented members we have here. I'm always available to chat, for that reason. I like to hear what people are up to. My current project is Chimera, but it's taken a lot of activation energy to get off the ground. I'm hoping I'll get some more motivation next weekend now that the holidays are over. Offline, I feel like I'm pretty average. I have an apartment that I like to keep clean, a car I like to keep fast, and a family I like to keep at a distance. I enjoy my work, especially now that I'm more settled in and done with college. I work mostly in cloud architecture and cloud computing, but I'm being moved to machine learning next week, which I look forward to. I've done a lot of odd software jobs in the past in cybersecurity, web programming, point of sales, industrial automation, test automation, etc. I tend to take interest in a lot of different topics, and I'd be interested to hear from anyone who works in machine learning, since that's what I'll be doing for the next few months. If I haven't said it already, welcome to the board, everyone. I'm happy to have you, and I'm happy to be here. Best, Spirited

Important Information

By using this site, you agree to our Terms of Use.