From abe9f3303d7970e38074150f35805ba924b29ed9 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 11 Apr 2016 21:29:07 +0300 Subject: Remove outdated tools. Look like they really outdated and unused. --- Reorganize.java | 198 ------------- outdated/dyecmd/CMakeLists.txt | 28 -- outdated/dyecmd/README | 12 - outdated/dyecmd/dyecmd.cbp | 56 ---- outdated/dyecmd/run.cmd | 1 - outdated/dyecmd/src/CMakeLists.txt | 59 ---- outdated/dyecmd/src/dye.cpp | 229 --------------- outdated/dyecmd/src/dye.h | 105 ------- outdated/dyecmd/src/dyecmd.cpp | 155 ----------- outdated/dyecmd/src/imagewriter.cpp | 113 -------- outdated/dyecmd/src/imagewriter.h | 31 --- outdated/generators/athena_template.txt | 1 - outdated/generators/genusers.py | 37 --- outdated/generators/save/.placeholder | 0 outdated/reformat/redormat.py | 72 ----- outdated/tmwcon/.gitignore | 6 - outdated/tmwcon/Converter.class | Bin 1985 -> 0 bytes outdated/tmwcon/MANIFEST.MF | 1 - outdated/tmwcon/README | 27 -- outdated/tmwcon/build.xml | 31 --- outdated/tmwcon/src/Converter.java | 54 ---- outdated/tmwcon/src/converter/Main.java | 110 -------- outdated/tmwcon/src/converter/Process.java | 246 ---------------- outdated/tmwcon/src/converter/WLKInterface.java | 29 -- outdated/tmwcon/tiled-core.jar | Bin 52337 -> 0 bytes outdated/tmwcon/tmw.jar | Bin 2767 -> 0 bytes outdated/tmxconverter/tmx_converter.py | 354 ------------------------ 27 files changed, 1955 deletions(-) delete mode 100644 Reorganize.java delete mode 100644 outdated/dyecmd/CMakeLists.txt delete mode 100644 outdated/dyecmd/README delete mode 100644 outdated/dyecmd/dyecmd.cbp delete mode 100644 outdated/dyecmd/run.cmd delete mode 100644 outdated/dyecmd/src/CMakeLists.txt delete mode 100755 outdated/dyecmd/src/dye.cpp delete mode 100755 outdated/dyecmd/src/dye.h delete mode 100755 outdated/dyecmd/src/dyecmd.cpp delete mode 100755 outdated/dyecmd/src/imagewriter.cpp delete mode 100755 outdated/dyecmd/src/imagewriter.h delete mode 100644 outdated/generators/athena_template.txt delete mode 100755 outdated/generators/genusers.py delete mode 100644 outdated/generators/save/.placeholder delete mode 100755 outdated/reformat/redormat.py delete mode 100644 outdated/tmwcon/.gitignore delete mode 100644 outdated/tmwcon/Converter.class delete mode 100644 outdated/tmwcon/MANIFEST.MF delete mode 100644 outdated/tmwcon/README delete mode 100755 outdated/tmwcon/build.xml delete mode 100644 outdated/tmwcon/src/Converter.java delete mode 100644 outdated/tmwcon/src/converter/Main.java delete mode 100644 outdated/tmwcon/src/converter/Process.java delete mode 100644 outdated/tmwcon/src/converter/WLKInterface.java delete mode 100644 outdated/tmwcon/tiled-core.jar delete mode 100644 outdated/tmwcon/tmw.jar delete mode 100644 outdated/tmxconverter/tmx_converter.py diff --git a/Reorganize.java b/Reorganize.java deleted file mode 100644 index 0b9c860..0000000 --- a/Reorganize.java +++ /dev/null @@ -1,198 +0,0 @@ -/* Reorganize (c) 2006 Bjørn Lindeijer - * License: GPL, v2 or later - */ - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.image.BufferedImage; -import java.util.Vector; -import java.io.IOException; -import java.io.File; -import javax.imageio.ImageIO; - -/** - * Tool to reorganize the headgears. - */ -public class Reorganize -{ - private static final int SPRITE_WIDTH = 60; - private static final int SPRITE_HEIGHT = 60; - private static final int FRAMES = 10; - private static final int DIRECTIONS = 4; - - private static final int HAIR_COLORS = 10; - private static final int HAIR_FRAMES = 9; - private static final int HAIR_SPRITE_WIDTH = 40; - private static final int HAIR_SPRITE_HEIGHT = 40; - - private static final int TRANSPARENT = new Color(255, 0, 255).getRGB(); - - public static void main(String[] arg) - { - if (arg.length != 2) { - System.out.println("Usage:\n java Reorganize [source] [target]"); - return; - } - - BufferedImage source = null; - try { - source = ImageIO.read(new File(arg[0])); - } catch (IOException e) { - System.out.println("Error while trying to read " + arg[0] + "."); - e.printStackTrace(); - System.exit(1); - } - - // Read the existing frames into a vector - Vector spriteSet = gridCut(source, - HAIR_SPRITE_WIDTH, HAIR_SPRITE_HEIGHT, - HAIR_FRAMES, 1); - - // Determine minimal rectangle that can still contain the contents of - // any frame - /* - Rectangle cropRect = minimumCropRect(spriteSet); - - if (cropRect == null) { - System.out.println( - "Error: no optimal crop rect could be determined."); - System.exit(1); - } - - System.out.println(arg[0] + ": width=\"" + - cropRect.width + "\" height=\"" + cropRect.height + "\""); - */ - - filterHeadgear(spriteSet); - - BufferedImage target = gridDraw( - spriteSet, - new Rectangle(0, 0, HAIR_SPRITE_WIDTH, HAIR_SPRITE_HEIGHT), - HAIR_FRAMES - 4, 1); - - // Save the target image - try { - ImageIO.write(target, "png", new File(arg[1])); - } catch (IOException e) { - System.out.println("Error while trying to write " + arg[1] + "."); - e.printStackTrace(); - System.exit(1); - } - } - - private static Vector gridCut( - BufferedImage source, - int width, int height, int xFrames, int yFrames) - { - Vector spriteSet = new Vector(); - - for (int y = 0; y < yFrames; y++) { - for (int x = 0; x < xFrames; x++) { - BufferedImage sprite = source.getSubimage( - x * width, - y * height, - width, - height); - - spriteSet.add(sprite); - } - } - - return spriteSet; - } - - private static BufferedImage gridDraw(Vector spriteSet, - Rectangle cropRect, int xFrames, int yFrames) - { - // Create a new image - BufferedImage target = new BufferedImage( - xFrames * cropRect.width, - yFrames * cropRect.height, - BufferedImage.TYPE_INT_ARGB); - - // Draw the frames onto the target image - Graphics g = target.getGraphics(); - for (int y = 0; y < yFrames; y++) { - for (int x = 0; x < xFrames; x++) { - g.drawImage( - spriteSet.get(x + xFrames * y).getSubimage( - cropRect.x, - cropRect.y, - cropRect.width, - cropRect.height), - x * cropRect.width, - y * cropRect.height, - null); - } - } - - return target; - } - - private static Rectangle minimumCropRect(Vector spriteSet) - { - Rectangle cropRect = null; - - for (BufferedImage sprite : spriteSet) { - Rectangle frameCropRect = determineCropRect(sprite); - - if (cropRect == null) { - cropRect = frameCropRect; - } else { - cropRect.add(frameCropRect); - } - } - - // Make crop rect one pixel larger (since we want an inclusive rect) - if (cropRect != null) { - cropRect.add( - cropRect.x + cropRect.width + 1, - cropRect.y + cropRect.height + 1); - } - - return cropRect; - } - - private static Rectangle determineCropRect(BufferedImage image) - { - // Loop through all the pixels, ignoring transparent ones. - Rectangle rect = null; - - for (int y = 0; y < image.getHeight(); y++) { - for (int x = 0; x < image.getWidth(); x++) { - int color = image.getRGB(x, y); - - if (color != TRANSPARENT && (color & 0xFF000000) != 0) { - if (rect == null) { - rect = new Rectangle(x, y, 0, 0); - } else { - rect.add(x, y); - } - } - } - } - - return rect; - } - - private static void filterHairstyle(Vector spriteSet) - { - // Remove frame 1, 2, 6 and 7 from each color - for (int i = HAIR_COLORS - 1; i >= 0; i--) { - spriteSet.remove(i * HAIR_FRAMES + 7); - spriteSet.remove(i * HAIR_FRAMES + 6); - spriteSet.remove(i * HAIR_FRAMES + 2); - spriteSet.remove(i * HAIR_FRAMES + 1); - } - } - - private static void filterHeadgear(Vector spriteSet) - { - // Remove frame 1, 2, 6 and 7 - spriteSet.remove(7); - spriteSet.remove(6); - spriteSet.remove(2); - spriteSet.remove(1); - } -} diff --git a/outdated/dyecmd/CMakeLists.txt b/outdated/dyecmd/CMakeLists.txt deleted file mode 100644 index 4856664..0000000 --- a/outdated/dyecmd/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -PROJECT(MANA_DYECOMMAND) - -IF (NOT VERSION) - SET(VERSION 1.0.0) -ENDIF() - -STRING(REPLACE "." " " _VERSION ${VERSION}) -SEPARATE_ARGUMENTS(_VERSION) -LIST(LENGTH _VERSION _LEN) -IF(NOT (_LEN EQUAL 4 OR _LEN EQUAL 3)) - MESSAGE(FATAL_ERROR "Version needs to be in the form MAJOR.MINOR.RELEASE[.BUILD]") -ENDIF() - -LIST(GET _VERSION 0 VER_MAJOR) -LIST(GET _VERSION 1 VER_MINOR) -LIST(GET _VERSION 2 VER_RELEASE) -IF(_LEN EQUAL 4) - LIST(GET _VERSION 3 VER_BUILD) -ELSE() - SET(VER_BUILD 0) -ENDIF() - -# where to look for cmake modules -SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/Modules) - -ADD_SUBDIRECTORY(src) diff --git a/outdated/dyecmd/README b/outdated/dyecmd/README deleted file mode 100644 index 050a765..0000000 --- a/outdated/dyecmd/README +++ /dev/null @@ -1,12 +0,0 @@ -DYECMD -======= - -This tool is used to dye item graphics used by the Mana client according to the -specification described here: http://wiki.themanaworld.org/index.php/Image_dyeing - -The tool expects 3 parameters: - -dyecmd -e.g.: -dyecmd "armor-legs-shorts.png" "armor-legs-shorts2.png" "W:#222255,6666ff" - diff --git a/outdated/dyecmd/dyecmd.cbp b/outdated/dyecmd/dyecmd.cbp deleted file mode 100644 index b3d1bb5..0000000 --- a/outdated/dyecmd/dyecmd.cbp +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - diff --git a/outdated/dyecmd/run.cmd b/outdated/dyecmd/run.cmd deleted file mode 100644 index 8672621..0000000 --- a/outdated/dyecmd/run.cmd +++ /dev/null @@ -1 +0,0 @@ -bin\debug\dyecmd "armor-legs-shorts.png" "armor-legs-shorts2.png" "W:#222255,6666ff" \ No newline at end of file diff --git a/outdated/dyecmd/src/CMakeLists.txt b/outdated/dyecmd/src/CMakeLists.txt deleted file mode 100644 index f8e717b..0000000 --- a/outdated/dyecmd/src/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -FIND_PACKAGE(SDL REQUIRED) -FIND_PACKAGE(SDL_image REQUIRED) -FIND_PACKAGE(PNG REQUIRED) - -IF (CMAKE_COMPILER_IS_GNUCXX) - # Help getting compilation warnings - SET(CMAKE_CXX_FLAGS "-Wall") - IF (WIN32) - # This includes enough debug information to get something useful - # from Dr. Mingw while keeping binary size down. Almost useless - # with gdb, though. - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb0 -gstabs2") - ENDIF() -ENDIF() - -SET(FLAGS "-DPACKAGE_VERSION=\\\"${VERSION}\\\"") -SET(FLAGS "${FLAGS} -DPKG_DATADIR=\\\"${PKG_DATADIR}/\\\"") -SET(FLAGS "${FLAGS} -DLOCALEDIR=\\\"${LOCALEDIR}/\\\"") - -IF (CMAKE_BUILD_TYPE) - STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) - IF((CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) OR - (CMAKE_BUILD_TYPE_TOLOWER MATCHES relwithdebinfo)) - SET(FLAGS "${FLAGS} -DDEBUG") - ENDIF() -ENDIF() - -INCLUDE_DIRECTORIES( - ${CMAKE_CURRENT_SOURCE_DIR} - ${SDL_INCLUDE_DIR} - ${SDLIMAGE_INCLUDE_DIR} - ${PNG_INCLUDE_DIR} - ) - -# Fix some stuff that gets not hidden by mainline modules -MARK_AS_ADVANCED(SDLIMAGE_INCLUDE_DIR) -MARK_AS_ADVANCED(SDLIMAGE_LIBRARY) -MARK_AS_ADVANCED(SDLMAIN_LIBRARY) -MARK_AS_ADVANCED(SDL_INCLUDE_DIR) -MARK_AS_ADVANCED(SDL_LIBRARY) - -SET(SRCS - dye.cpp - dye.h - dyecmd.cpp - imagewriter.cpp - imagewriter.h - ) - -SET (PROGRAMS dyecmd) - -ADD_EXECUTABLE(dyecmd WIN32 ${SRCS}) - -TARGET_LINK_LIBRARIES(dyecmd - ${SDL_LIBRARY} - ${SDLIMAGE_LIBRARY} - ${PNG_LIBRARIES}) - -SET_TARGET_PROPERTIES(dyecmd PROPERTIES COMPILE_FLAGS "${FLAGS}") diff --git a/outdated/dyecmd/src/dye.cpp b/outdated/dyecmd/src/dye.cpp deleted file mode 100755 index 760ff23..0000000 --- a/outdated/dyecmd/src/dye.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2007-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * - * This file is part of The Mana Client. - * - * This program 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 - * any later version. - * - * This program 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 program. If not, see . - */ - -#include -#include -#include -#include - -#include "dye.h" - -Palette::Palette(const std::string &description) -{ - mLoaded = false; - int size = description.length(); - if (size == 0) return; - if (description[0] != '#') - { - std::cout << "Missing # in the palette description " - << "in the third parameter." << std::endl; - return; - } - - int pos = 1; - for (;;) - { - if (pos + 6 > size) break; - int v = 0; - for (int i = 0; i < 6; ++i) - { - char c = description[pos + i]; - int n; - if ('0' <= c && c <= '9') - n = c - '0'; - else if ('A' <= c && c <= 'F') - n = c - 'A' + 10; - else if ('a' <= c && c <= 'f') - n = c - 'a' + 10; - else - { - std::cout << "invalid Hexadecimal description: " - << description << std::endl; - return; - } - - v = (v << 4) | n; - } - Color c = { { v >> 16, v >> 8, v } }; - mColors.push_back(c); - pos += 6; - if (pos == size) - { - mLoaded = true; - return; - } - if (description[pos] != ',') - break; - - ++pos; - } - - mLoaded = true; -} - -void Palette::getColor(int intensity, int color[3]) const -{ - printf ("---------------------------------------------\n"); - printf ("intensity=%x\n", intensity); - printf ("image color: %x, %x, %x\n", color[0], color[1], color[2]); - - // Return implicit black - if (intensity == 0) - { - color[0] = 0; - color[1] = 0; - color[2] = 0; - printf ("set color to zero\n"); - return; - } - - int last = mColors.size(); - printf ("last=%d\n", last); - if (last == 0) - return; - - int i = intensity * last / 255; - int t = intensity * last % 255; - - printf ("i = intensity * last / 255 = %d\n", i); - printf ("t = intensity * last %% 255 = %d\n", t); - - int j = t != 0 ? i : i - 1; - printf ("j = t != 0 ? i : i - 1 = %d\n", j); - // Get the exact color if any, the next color otherwise. - int r2 = mColors[j].value[0], - g2 = mColors[j].value[1], - b2 = mColors[j].value[2]; - - printf ("read from palate at j (%d)\n", j); - printf ("r2 = mColors[j].value[0]=%x\n", r2); - printf ("g2 = mColors[j].value[1]=%x\n", g2); - printf ("b2 = mColors[j].value[2]=%x\n", b2); - - if (t == 0) - { - printf ("t == 0, return rgb = %x, %x, %x\n", r2, g2, b2); - // Exact color. - color[0] = r2; - color[1] = g2; - color[2] = b2; - return; - } - - // Get the previous color. First color is implicitly black. - int r1 = 0, g1 = 0, b1 = 0; - printf ("r1=g1=b1=0\n"); - if (i > 0) - { - r1 = mColors[i - 1].value[0]; - g1 = mColors[i - 1].value[1]; - b1 = mColors[i - 1].value[2]; - printf ("read from palate at i-1 (%d)\n", i - 1); - printf ("r1 = mColors[i - 1].value[0] = %x\n", r1); - printf ("g1 = mColors[i - 1].value[1] = %x\n", g1); - printf ("b1 = mColors[i - 1].value[2] = %x\n", b1); - } - - // Perform a linear interpolation. - color[0] = ((255 - t) * r1 + t * r2) / 255; - color[1] = ((255 - t) * g1 + t * g2) / 255; - color[2] = ((255 - t) * b1 + t * b2) / 255; - printf ("result color:\n"); - printf ("color[0] = ((255 - t) * r1 + t * r2) / 255 = %d * %d + %d * %d = %x\n", 255 - t, r1, t, r2, color[0]); - printf ("color[1] = ((255 - t) * g1 + t * g2) / 255 = %d * %d + %d * %d = %x\n", 255 - t, g1, t, g2, color[1]); - printf ("color[2] = ((255 - t) * b1 + t * b2) / 255 = %d * %d + %d * %d = %x\n", 255 - t, b1, t, b2, color[2]); -} - -Dye::Dye(const std::string &description) -{ - mLoaded = false; - for (int i = 0; i < 7; ++i) - mPalettes[i] = 0; - - if (description.empty()) return; - - std::string::size_type next_pos = 0, length = description.length(); - do - { - std::string::size_type pos = next_pos; - next_pos = description.find(';', pos); - if (next_pos == std::string::npos) - next_pos = length; - if (next_pos <= pos + 3 || description[pos + 1] != ':') - { - std::cout << "Dyeing: Missing ':' in channel description." - << std::endl; - return; - } - int i = 0; - switch (description[pos]) - { - case 'R': i = 0; break; - case 'G': i = 1; break; - case 'Y': i = 2; break; - case 'B': i = 3; break; - case 'M': i = 4; break; - case 'C': i = 5; break; - case 'W': i = 6; break; - default: - std::cout << "Dyeing: Invalid channel. Not in [R,G,Y,B,M,C,W]" - << std::endl; - return; - } - mPalettes[i] = new Palette( - description.substr(pos + 2, next_pos - pos - 2)); - - if (!mPalettes[i]->loaded()) - return; - - ++next_pos; - } - while (next_pos < length); - - mLoaded = true; -} - -Dye::~Dye() -{ - for (int i = 0; i < 7; ++i) - delete mPalettes[i]; -} - -void Dye::update(int color[3]) const -{ - int cmax = std::max(color[0], std::max(color[1], color[2])); - if (cmax == 0) return; - - int cmin = std::min(color[0], std::min(color[1], color[2])); - int intensity = color[0] + color[1] + color[2]; - - if (cmin != cmax && - (cmin != 0 || (intensity != cmax && intensity != 2 * cmax))) - { - // not pure - return; - } - - int i = (color[0] != 0) | ((color[1] != 0) << 1) | ((color[2] != 0) << 2); - - if (mPalettes[i - 1]) - mPalettes[i - 1]->getColor(cmax, color); -} diff --git a/outdated/dyecmd/src/dye.h b/outdated/dyecmd/src/dye.h deleted file mode 100755 index 922f337..0000000 --- a/outdated/dyecmd/src/dye.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2007-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * - * This file is part of The Mana Client. - * - * This program 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 - * any later version. - * - * This program 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 program. If not, see . - */ - -#ifndef DYE_H -#define DYE_H - -#include - -#include - -/** - * Class for performing a linear interpolation between colors. - */ -class Palette -{ - public: - - /** - * Creates a palette based on the given string. - * The string is either a file name or a sequence of hexadecimal RGB - * values separated by ',' and starting with '#'. - */ - Palette(const std::string &); - - /** - * Gets a pixel color depending on its intensity. - */ - void getColor(int intensity, int color[3]) const; - - /** - * Tells if the palette was successfully loaded. - */ - bool loaded() const - { return mLoaded; } - - private: - - struct Color { unsigned char value[3]; }; - - std::vector< Color > mColors; - - bool mLoaded; -}; - -/** - * Class for dispatching pixel-recoloring amongst several palettes. - */ -class Dye -{ - public: - - /** - * Creates a set of palettes based on the given string. - * - * The parts of string are separated by semi-colons. Each part starts - * by an uppercase letter, followed by a colon and then a palette name. - */ - Dye(const std::string &); - - /** - * Destroys the associated palettes. - */ - ~Dye(); - - /** - * Tells if the dye description was successfully loaded. - */ - bool loaded() const - { return mLoaded; } - - /** - * Modifies a pixel color. - */ - void update(int color[3]) const; - - private: - - /** - * The order of the palettes, as well as their uppercase letter, is: - * - * Red, Green, Yellow, Blue, Magenta, White (or rather gray). - */ - Palette *mPalettes[7]; - bool mLoaded; -}; - -#endif diff --git a/outdated/dyecmd/src/dyecmd.cpp b/outdated/dyecmd/src/dyecmd.cpp deleted file mode 100755 index 5e06e50..0000000 --- a/outdated/dyecmd/src/dyecmd.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * - * This file is part of The Mana Client. - * - * This program 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 - * any later version. - * - * This program 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 program. If not, see . - */ - -#include -#include -#include - -#include "dye.h" -#include "imagewriter.h" - -using namespace std; - -// return values -enum ReturnValues -{ - RETURN_OK = 0, - INVALID_PARAMETER_LIST = 100, - INVALID_INPUT_IMAGE = 101, - INVALID_OUTPUT_IMAGE = 102, - INVALID_DYE_PARAMETER = 105 -}; - -SDL_Surface* recolor(SDL_Surface* tmpImage, Dye* dye) -{ - SDL_PixelFormat rgba; - rgba.palette = NULL; - rgba.BitsPerPixel = 32; - rgba.BytesPerPixel = 4; - rgba.Rmask = 0xFF000000; rgba.Rloss = 0; rgba.Rshift = 24; - rgba.Gmask = 0x00FF0000; rgba.Gloss = 0; rgba.Gshift = 16; - rgba.Bmask = 0x0000FF00; rgba.Bloss = 0; rgba.Bshift = 8; - rgba.Amask = 0x000000FF; rgba.Aloss = 0; rgba.Ashift = 0; - rgba.colorkey = 0; - rgba.alpha = 255; - - SDL_Surface *surf = SDL_ConvertSurface(tmpImage, &rgba, SDL_SWSURFACE); - //SDL_FreeSurface(tmpImage); <-- We'll free the surface later. - - Uint32 *pixels = static_cast< Uint32 * >(surf->pixels); - for (Uint32 *p_end = pixels + surf->w * surf->h; pixels != p_end; ++pixels) - { - int alpha = (*pixels >> rgba.Ashift) & 255; - if (!alpha) continue; - int v[3]; - - v[0] = (*pixels >> rgba.Rshift) & 255; - v[1] = (*pixels >> rgba.Gshift) & 255; - v[2] = (*pixels >> rgba.Bshift) & 255; - dye->update(v); - -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - *pixels = (v[0] << 24) | (v[1] << 16) | (v[2] << 8) | alpha; -#else - *pixels = v[0] | (v[1] << 8) | (v[2] << 16) | (alpha << 24); -#endif - } - - return surf; -} - -void printHelp() -{ - cout << endl - << "This tool is used to dye item graphics used by the Mana client " - << "according to the specification described here: " - << endl << "http://doc.manasource.org/image_dyeing_system" - << endl << endl << - "The tool expects 3 parameters:" << endl - << "dyecmd " << endl - << "e.g.:" << endl - << "dyecmd \"armor-legs-shorts.png\" " - <<"\"armor-legs-shorts2.png\" \"W:#222255,6666ff\"" << std::endl; -} - -int main(int argc, char* argv[]) -{ - Dye* dye = NULL; - SDL_Surface* source = NULL, *target = NULL; - ReturnValues returnValue = RETURN_OK; - - if (argc > 1 && (!strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))) - { - printHelp(); - } - // not enough or to many parameters - else if (argc != 4) - { - cout << INVALID_PARAMETER_LIST << " - INVALID_PARAMETER_LIST"; - printHelp(); - returnValue = INVALID_PARAMETER_LIST; - } - else - { - // Start dyeing process. - string inputFile = argv[1]; - string outputFile = argv[2]; - string dyeDescription = argv[3]; - - dye = new Dye(dyeDescription); - if (!dye->loaded()) - { - cout << INVALID_DYE_PARAMETER << " - INVALID_DYE_PARAMETER"; - printHelp(); - returnValue = INVALID_DYE_PARAMETER; - } - else - { - source = IMG_Load(inputFile.c_str()); - if (!source) - { - cout << INVALID_INPUT_IMAGE << " - INVALID_INPUT_IMAGE"; - printHelp(); - returnValue = INVALID_INPUT_IMAGE; - } - else - { - target = recolor(source, dye); - - if (!ImageWriter::writePNG(target, outputFile)) - { - cout << INVALID_OUTPUT_IMAGE << " - INVALID_OUTPUT_IMAGE"; - printHelp(); - returnValue = INVALID_OUTPUT_IMAGE; - } - } // Valid source image file - } // Valid dye parameter - } // Parameters ok - - if (source) - SDL_FreeSurface(source); - if (target) - SDL_FreeSurface(target); - if (dye) - delete dye; - - return returnValue; -} diff --git a/outdated/dyecmd/src/imagewriter.cpp b/outdated/dyecmd/src/imagewriter.cpp deleted file mode 100755 index d237abb..0000000 --- a/outdated/dyecmd/src/imagewriter.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * - * This file is part of The Mana Client. - * - * This program 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 - * any later version. - * - * This program 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 program. If not, see . - */ - -#include "imagewriter.h" - -#include -#include -#include -#include - -bool ImageWriter::writePNG(SDL_Surface *surface, - const std::string &filename) -{ - // TODO Maybe someone can make this look nice? - FILE *fp = fopen(filename.c_str(), "wb"); - if (!fp) - { - std::cout << "PNG writer: Could not open file for writing: " - << filename << std::endl; - return false; - } - - png_structp png_ptr; - png_infop info_ptr; - png_bytep *row_pointers; - int colortype; - - if (SDL_MUSTLOCK(surface)) { - SDL_LockSurface(surface); - } - - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); - if (!png_ptr) - { - std::cout << "PNG writer: Had trouble creating png_structp" - << std::endl; - return false; - } - - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - std::cout << "PNG writer: Could not create png_info" << std::endl; - return false; - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - std::cout << "PNG writer: problem writing to : " - << filename << std::endl; - return false; - } - - png_init_io(png_ptr, fp); - - colortype = (surface->format->BitsPerPixel == 24) ? - PNG_COLOR_TYPE_RGB : PNG_COLOR_TYPE_RGB_ALPHA; - - png_set_IHDR(png_ptr, info_ptr, surface->w, surface->h, 8, colortype, - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); - - png_write_info(png_ptr, info_ptr); - - png_set_packing(png_ptr); - - row_pointers = new png_bytep[surface->h]; - if (!row_pointers) - { - std::cout - << "PNG writer: Had trouble converting surface to row pointers" - << std::endl; - return false; - } - - for (int i = 0; i < surface->h; i++) - { - row_pointers[i] = (png_bytep)(Uint8 *)surface->pixels + i * surface->pitch; - } - - png_write_image(png_ptr, row_pointers); - png_write_end(png_ptr, info_ptr); - - fclose(fp); - - delete [] row_pointers; - - png_destroy_write_struct(&png_ptr, (png_infopp)NULL); - - if (SDL_MUSTLOCK(surface)) - SDL_UnlockSurface(surface); - - return true; -} diff --git a/outdated/dyecmd/src/imagewriter.h b/outdated/dyecmd/src/imagewriter.h deleted file mode 100755 index a8bcdf5..0000000 --- a/outdated/dyecmd/src/imagewriter.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * The Mana Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * - * This file is part of The Mana Client. - * - * This program 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 - * any later version. - * - * This program 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 program. If not, see . - */ - -#include - -struct SDL_Surface; - -class ImageWriter -{ - public: - static bool writePNG(SDL_Surface *surface, - const std::string &filename); -}; diff --git a/outdated/generators/athena_template.txt b/outdated/generators/athena_template.txt deleted file mode 100644 index 325c87a..0000000 --- a/outdated/generators/athena_template.txt +++ /dev/null @@ -1 +0,0 @@ - 0,1,1 0,0,50 43,43,11,11 9,9,9,1,1,1 0,0 0,0,0 0,0,0 6,10,0 0,0,0,1108,0 002-3.gat,23,22 002-3.gat,16,18,0,0 0,1108,1,512,1,0,0,0,0,0,0,0 1,0 diff --git a/outdated/generators/genusers.py b/outdated/generators/genusers.py deleted file mode 100755 index 7371413..0000000 --- a/outdated/generators/genusers.py +++ /dev/null @@ -1,37 +0,0 @@ -#! /usr/bin/env python2.6 -# -*- coding: utf8 -*- -# -# Copyright (C) 2011 Evol Online -# Author: Andrei Karas (4144) - -import os -import re - -with open ("save/account.txt", "w") as w: - w.write("0\ts1\tp1\t2011-01-21 00:08:54.247\tS\t905\t0\ta@a.com\t-\t0\t127.0.0.1\t!\t0\t") - for f in range(2000000, 2010000): - w.write(str(f)) - w.write("\t") - w.write("u" + str(f) + "aaa\t") - w.write("!aaaaa$aaaaaaaaaaaaaaaaaaaaaaaa") - w.write("\t2011-01-20 01:09:48.708\tM\t1\t0\t") - w.write("a@a.com\t-\t0\t127.0.0.1\t!\t0\t\n") - w.write("2010000\t%newid%\n") - -with open ("athena_template.txt") as r: - template = r.read() - num = 2 - with open ("save/athena.txt", "w") as w: - for f in range(150000, 155000): - for d in range(0, num): - w.write(str((f-150000)*num*10 + d + 150000)) - w.write("\t") - w.write(str(f-150000+2000000)) - w.write(",") - w.write(str(d)) - w.write("\t") - w.write("u" + str(f) + "aaa" + str(d)) - w.write(template) - w.write(str((f-150000)*num*10 + d + 150000 + 1)) - w.write("\t%newid%\n") - diff --git a/outdated/generators/save/.placeholder b/outdated/generators/save/.placeholder deleted file mode 100644 index e69de29..0000000 diff --git a/outdated/reformat/redormat.py b/outdated/reformat/redormat.py deleted file mode 100755 index 75b2d95..0000000 --- a/outdated/reformat/redormat.py +++ /dev/null @@ -1,72 +0,0 @@ -#! /usr/bin/env python2.6 -# -*- coding: utf8 -*- - -import os -import re - -def calcSize(str): - sz = 0 - for chr in str: - if chr != '\t': - sz = sz + 1 - return sz + 1 - - - -strre = re.compile(",") -with open ("item_db.txt", "r") as r: - with open ("item_db2.txt", "w") as w: - lines = []; - for line in r: - arr = strre.split(line) - if line[0] == '#': - lines.append(line) - continue - text = [] - - for item in arr: - text.append(item.strip()) - - lines.append(text) - - maxSize = 0 - minSize = 100 - for line in lines: - if len(line[1]) > 1: - if len(line) > maxSize: - maxSize = len(line) - if len(line) < minSize: - minSize = len(line) - - minSize = 19 - sizes = [] - for k in range(0, minSize): - sz = 6 - for line in lines: - if len(line[k]) > sz: - sz = len(line[k]) - if sz < 3: - sz = 4 - elif sz > 6: - sz = 24 - sizes.append(sz + 1) - - print sizes - for k in range(0, minSize): - for line in lines: - if len(line[1]) > 1: - line[k] = line[k] + "," - while len(line[k]) < sizes[k]: - line[k] = line[k] + " " - - for line in lines: - if len(line[1]) == 1: - w.write(line) - else: - for item in line: - w.write(item) - w.write("\n") - - print minSize - print maxSize - diff --git a/outdated/tmwcon/.gitignore b/outdated/tmwcon/.gitignore deleted file mode 100644 index 7123179..0000000 --- a/outdated/tmwcon/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -# java converter -converter.jar -server-data/ -summary.txt -tmwdata -build diff --git a/outdated/tmwcon/Converter.class b/outdated/tmwcon/Converter.class deleted file mode 100644 index f96b708..0000000 Binary files a/outdated/tmwcon/Converter.class and /dev/null differ diff --git a/outdated/tmwcon/MANIFEST.MF b/outdated/tmwcon/MANIFEST.MF deleted file mode 100644 index 954575d..0000000 --- a/outdated/tmwcon/MANIFEST.MF +++ /dev/null @@ -1 +0,0 @@ -Main-Class: converter.Main diff --git a/outdated/tmwcon/README b/outdated/tmwcon/README deleted file mode 100644 index a48fc83..0000000 --- a/outdated/tmwcon/README +++ /dev/null @@ -1,27 +0,0 @@ -Dependencies: - - * ant (recent version) - * J2SE 5 or higher (or equivalent) - * Tiled or Tiled core jar file (in this directory) - * TMW Tiled plugin jar (in this directory or the plugins directory) - -Compilation: - - Run ant from this directory. - -Usage: - - * Create a directory called tmwdata containing the client data - (can be symlink) - - * Output will be in a directory called server-data - (usually you make this a symlink to eathena-data) - - * If the aforementioned jar files are in class path you can run the - converter jar file directly: - - java -jar converter.jar - - Otherwise, the Converter class can handle that for you: - - java Converter diff --git a/outdated/tmwcon/build.xml b/outdated/tmwcon/build.xml deleted file mode 100755 index b2937e6..0000000 --- a/outdated/tmwcon/build.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - A tool to convert map data from TMWServ format to eAthena format - - - - - - - - - - - - - - - - - - - - - - - diff --git a/outdated/tmwcon/src/Converter.java b/outdated/tmwcon/src/Converter.java deleted file mode 100644 index 0f245aa..0000000 --- a/outdated/tmwcon/src/Converter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * TMWServ to eAthena Converter (c) 2008 Jared Adams - * License: GPL, v2 or later - */ - -import java.io.*; -import java.lang.reflect.*; -import java.net.*; -import java.util.*; - -public abstract class Converter { - static String[] tiledJars = {"tiled-core.jar", "tiled.jar"}; - static String[] wlkJars = {"plugins/tmw.jar", "tmw.jar"}; - - public static void main(String[] args) throws Exception { - List urls = new ArrayList(); - - File tiled = null; - for (String s : tiledJars) { - tiled = new File(s); - if (tiled.exists()) break; - } - if (tiled == null || !tiled.exists()) { - System.err.println("Unable to find a Tiled jar file! Exiting."); - System.exit(-5); - } - urls.add(tiled.toURI().toURL()); - - File wlkWriter = null; - for (String s : wlkJars) { - wlkWriter = new File(s); - if (wlkWriter.exists()) break; - } - if (wlkWriter == null || !wlkWriter.exists()) { - System.err.println("Unable to find the tmw plugin for Tiled! No wlk files will be made!"); - } else { - urls.add(wlkWriter.toURI().toURL()); - } - - File self = new File("converter.jar"); - if (!self.exists()) { - System.err.println("Unable to find a the converter jar! Exiting."); - System.exit(-5); - } - urls.add(self.toURI().toURL()); - - URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[0])); - Class c = loader.loadClass("converter.Main"); - Method m = c.getMethod("run", String[].class, Integer.TYPE); - System.out.println("Starting"); - - m.invoke(null, args, 0); - } -} diff --git a/outdated/tmwcon/src/converter/Main.java b/outdated/tmwcon/src/converter/Main.java deleted file mode 100644 index 80dfe30..0000000 --- a/outdated/tmwcon/src/converter/Main.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * TMWServ to eAthena Converter (c) 2008 Jared Adams - * License: GPL, v2 or later - */ - -package converter; - -import java.io.*; -import java.util.*; - -import tiled.io.xml.*; - -public class Main { - public static XMLMapTransformer reader = null; - - private static tiled.core.Map loadMap(File file) { - tiled.core.Map map = null; - try { - map = reader.readMap(file.getAbsolutePath()); - } catch (Exception e) { - e.printStackTrace(); - } - - return map; - } - - public static boolean isTMX(File in) { - if (in.isDirectory()) return false; - - return in.getName().matches(".*\\.tmx(\\.gz)?$"); - } - - public static Collection getTMXFiles(File directory) { - if (!directory.isDirectory()) return Collections.emptyList(); - - List ret = new Vector(); - - for (File f : directory.listFiles()) { - if (f.isDirectory()) { - ret.addAll(getTMXFiles(f)); - } else if (isTMX(f)) { - ret.add(f); - } - } - - return ret; - } - - public static PrintWriter getWriter(File f) { - try { - f.createNewFile(); - return new PrintWriter(f); - } catch (Exception e) { - e.printStackTrace(); - } - - return null; - } - - public static String getName(File folder, File file) { - String path = folder.getAbsolutePath(); - String name = file.getAbsolutePath(); - if (name.startsWith(path)) name = name.substring(path.length() + 1); - if (name.endsWith(".gz")) name = name.substring(0, name.length() - 3); - if (name.endsWith(".tmx")) name = name.substring(0, name.length() - 4); - return name; - } - - public static void run(String[] args, int unused) { - reader = new XMLMapTransformer(); - - PrintWriter summary = null; - - try { - File temp = new File("summary.txt"); - temp.createNewFile(); - summary = new PrintWriter(temp); - } catch (Exception e) { - System.out.println("Problem opening summary file for writing:"); - e.printStackTrace(); - } - - File folder = new File("server-data/data/"); - folder.mkdirs(); - Process.prepWLK(folder); - - folder = new File("tmwdata/maps/"); - - Collection tmxs = getTMXFiles(folder); - Vector folders = new Vector(); - String name; - for (File f : tmxs) { - name = getName(folder, f); - System.out.printf("== %s ==\n", name); - if (summary != null) summary.printf("== %s ==\n", name); - folders.add(Process.processMap(name, loadMap(f), f, summary)); - } - - if (summary != null) { - summary.flush(); - summary.close(); - } - - Process.writeMasterImport(folders.toArray(new String[0])); - } - - public static void main(String[] args) { - run(args, 0); - } -} diff --git a/outdated/tmwcon/src/converter/Process.java b/outdated/tmwcon/src/converter/Process.java deleted file mode 100644 index 2e7103e..0000000 --- a/outdated/tmwcon/src/converter/Process.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * TMWServ to eAthena Converter (c) 2008 Jared Adams - * License: GPL, v2 or later - */ - -package converter; - -import java.awt.*; -import java.io.*; -import java.util.Iterator; -import java.util.Properties; -import java.util.TreeSet; -import java.util.ArrayList; -import java.util.List; -import java.util.Collections; - -import tiled.core.*; -import tiled.plugins.tmw.*; - -public class Process { - private static final String baseFolder = "server-data/"; - private static final File _baseFolder = new File(baseFolder); - private static final String scriptDirectory = "npc/"; - private static final String mobFile = "_mobs.txt"; - private static final String warpFile = "_warps.txt"; - private static final String importFile = "_import.txt"; - private static File wlkFolder; - - private static WLKInterface wlk = null; - - public static void prepWLK(File folder) { - wlkFolder = folder; - try { - wlk = new WLKInterface(); - } catch (NoClassDefFoundError ncdfe) {} - } - - private static String getProp(Properties props, String name, String def) { - if (name == null) return def; - for (java.util.Map.Entry entry : props.entrySet()) { - if (name.equalsIgnoreCase(entry.getKey().toString())) { - return entry.getValue().toString(); - } - } - return def; - } - - private static int getProp(Properties props, String name, int def) { - if (name == null) return def; - try { - return Integer.parseInt(getProp(props, name, "?")); - } catch (Exception e) {} - return def; - } - - private static int[] resolveBounds(Rectangle in, boolean warp) { - int x = Math.round((float)in.x / (float)32); - int y = Math.round((float)in.y / (float)32); - int width = Math.round((float)in.width / (float)32); - int height = Math.round((float)in.height / (float)32); - if (!warp) { - if (width > 1) --width; - if (height > 1) --height; - } - x += width / 2; - y += height / 2; - if (warp) { - width -= 2; - height -= 2; - } - return new int[]{x, y, width, height}; - } - - private static void handleWarp(PrintWriter out, String map, String name, Rectangle bounds, Properties props) { - if (out == null) return; - String dest = getProp(props, "dest_map", null); - if (dest == null) return; - int x = getProp(props, "dest_tile_x", -1); - if (x < 0) - { - x = getProp(props, "dest_x", -1); - if (x < 0) return; - x = Math.round((float)x / (float)32); - } - int y = getProp(props, "dest_tile_y", -1); - if (y < 0) - { - y = getProp(props, "dest_y", -1); - if (y < 0) return; - y = Math.round((float)y / (float)32); - } - int[] shape = resolveBounds(bounds, true); - System.out.printf("Usable warp found: %s\n", name); - out.printf("%s.gat,%d,%d\twarp\t%s\t%d,%d,%s.gat,%d,%d\n", map, shape[0], shape[1], name, shape[2], shape[3], dest, x, y); - } - - private static int handleMob(PrintWriter out, String map, String name, Rectangle bounds, Properties props) { - if (out == null) return -1; - int mob = getProp(props, "monster_id", -1); - if (mob < 0) return -1; - mob += 1002; - int max = getProp(props, "max_beings", 1); - int time1 = getProp(props, "eA_spawn", 0); - int time2 = getProp(props, "eA_death", 0); - int[] shape = resolveBounds(bounds, false); - System.out.printf("Usable mob found: %s (%d)\n", name, mob); - out.printf("%s.gat,%d,%d,%d,%d\tmonster\t%s\t%d,%d,%d,%d,Mob%s::On%d\n", map, shape[0], shape[1], shape[2], shape[3], name, mob, max, time1, time2, map, mob); - return mob; - } - - private static void processObject(MapObject mo, String map, PrintWriter warpOut, PrintWriter mobOut, TreeSet mobs) { - if (mo == null) return; - String name = mo.getName(); - String type = mo.getType(); - Rectangle bounds = new Rectangle(mo.getBounds()); - Properties props = mo.getProperties(); - - if (type.equalsIgnoreCase("warp")) { - handleWarp(warpOut, map, name, bounds, props); - } else if (type.equalsIgnoreCase("spawn")) { - mobs.add(handleMob(mobOut, map, name, bounds, props)); - } - } - - private static void processObjects(Iterator objs, String map, PrintWriter warpOut, PrintWriter mobOut, TreeSet mobs) { - MapObject mo; - while (objs.hasNext()) { - mo = objs.next(); - if (mo == null) continue; - processObject(mo, map, warpOut, mobOut, mobs); - } - } - - private static void processFiles(File folder, List out) { - for (File f : folder.listFiles()) { - if (f.isDirectory()) { - processFiles(folder, out); - } else if (!f.getName().equals(importFile)) { - out.add("npc: " + f.getPath().substring(_baseFolder.getPath().length() + 1)); - } - } - } - - private static void makeInclude(String name, File folder) { - File _import = new File(folder, importFile); - List output_elements = new ArrayList(); - processFiles(folder, output_elements); - PrintWriter importOut = Main.getWriter(_import); - importOut.printf("map: %s.gat\n", name); - Collections.sort(output_elements); - for (String s : output_elements) - importOut.println(s); - importOut.flush(); - importOut.close(); - } - - public static String processMap(String name, Map map, File mapFile, PrintWriter summary) { - if (name == null) return null; - if (map == null) return null; - - Properties props = map.getProperties(); - String title = getProp(props, "name", ""); - - String folderName = scriptDirectory + name; - if (title.length() > 0) { - folderName += "_" + title.replaceAll("\\s", "_").replaceAll("[^A-Za-z0-9\\-_]", ""); - title = name + " " + title; - } else { - title = name; - } - - File folder = new File(baseFolder + folderName); - folder.mkdirs(); - - System.out.println(title); - - File wlkFile = new File(wlkFolder, name + ".wlk"); - - if (wlkFile.exists() && mapFile.lastModified() < wlkFile.lastModified()) { - System.out.println("Up to date, skipping"); - makeInclude(name, folder); - return folderName; - } - - if (summary != null) { - summary.printf("\tName: '%s'\n", title); - summary.printf("\tMusic: '%s'\n", getProp(props, "music", "")); - summary.printf("\tMinimap: '%s'\n", getProp(props, "minimap", "")); - } - - if (wlk != null) wlk.write(name, map, wlkFile); - - PrintWriter warpOut = Main.getWriter(new File(folder, warpFile)); - PrintWriter mobOut = Main.getWriter(new File(folder, mobFile)); - - warpOut.printf("// %s warps\n\n", title); - mobOut.printf("// %s mobs\n\n", title); - - TreeSet mobs = new TreeSet(); - processObjects(map.getObjects(), name, warpOut, mobOut, mobs); - for (MapLayer layer : map) { - if (layer instanceof ObjectGroup) { - processObjects(((ObjectGroup) layer).getObjects(), name, warpOut, mobOut, mobs); - } - } - - warpOut.flush(); - warpOut.close(); - - System.out.println("Starting mob points"); - mobOut.printf("\n\n%s.gat,0,0,0\tscript\tMob%1$s\t-1,{\n", name); - for (int mob : mobs) { - if (mob == -1) continue; - mobOut.printf("On%d:\n\tset @mobID, %d;\n\tcallfunc \"MobPoints\";\n\tbreak;\n\n", mob, mob); - } - mobOut.printf("\tend;\n}\n"); - System.out.println("Finished mob points"); - - mobOut.flush(); - mobOut.close(); - - makeInclude(name, folder); - - return folderName; - } - - public static void writeMasterImport(String[] folders) { - File master = new File(baseFolder + scriptDirectory + "_import.txt"); - PrintWriter out = Main.getWriter(master); - if (out == null) return; - - List output_elements = new ArrayList(); - - for (String folder : folders) { - if (folder == null) continue; - output_elements.add("import: " + folder + "/_import.txt"); - } - - Collections.sort(output_elements); - for (String s : output_elements) - out.println(s); - - out.flush(); - out.close(); - } -} diff --git a/outdated/tmwcon/src/converter/WLKInterface.java b/outdated/tmwcon/src/converter/WLKInterface.java deleted file mode 100644 index b9e0cb2..0000000 --- a/outdated/tmwcon/src/converter/WLKInterface.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * TMWServ to eAthena Converter (c) 2008 Jared Adams - * License: GPL, v2 or later - */ - -package converter; - -import java.io.*; - -import tiled.core.*; -import tiled.plugins.tmw.*; - -public class WLKInterface { - public WLKInterface() { - // See if the writer is available - WLKWriter.class.getName(); - } - - public void write(String name, Map map, File wlk) { - try { - wlk.createNewFile(); - WLKWriter.writeMap(map, new FileOutputStream(wlk)); - System.out.println("WLK written"); - } catch (Exception e) { - System.out.println("Prolem writing WLK file:"); - e.printStackTrace(); - } - } -} diff --git a/outdated/tmwcon/tiled-core.jar b/outdated/tmwcon/tiled-core.jar deleted file mode 100644 index 78d44bc..0000000 Binary files a/outdated/tmwcon/tiled-core.jar and /dev/null differ diff --git a/outdated/tmwcon/tmw.jar b/outdated/tmwcon/tmw.jar deleted file mode 100644 index 3dfd070..0000000 Binary files a/outdated/tmwcon/tmw.jar and /dev/null differ diff --git a/outdated/tmxconverter/tmx_converter.py b/outdated/tmxconverter/tmx_converter.py deleted file mode 100644 index ac1ba1d..0000000 --- a/outdated/tmxconverter/tmx_converter.py +++ /dev/null @@ -1,354 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -## tmx_converter.py - Extract walkmap, warp, and spawn information from maps. -## -## Copyright © 2012 Ben Longbons -## -## This file is part of The Mana World -## -## This program 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 program 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 program. If not, see . - - -from __future__ import print_function - -import sys -import os -import posixpath -import struct -import xml.sax -import base64 -import zlib - -dump_all = False # wall of text - -# lower case versions of everything except 'spawn' and 'warp' -other_object_types = set([ - 'particle_effect', - 'npc', # not interpreted by client - 'script', # for ManaServ - 'fixme', # flag for things that didn't have a type before -]) - -# Somebody has put ManaServ fields in our data! -other_spawn_fields = ( - 'spawn_rate', -) -other_warp_fields = ( -) - -TILESIZE = 32 -SEPARATOR = '|' -MESSAGE = 'This file is generated automatically. All manually changes will be removed when running the Converter.' -CLIENT_MAPS = 'maps' -SERVER_WLK = 'data' -SERVER_NPCS = 'npc' -NPC_MOBS = '_mobs.txt' -NPC_WARPS = '_warps.txt' -NPC_IMPORTS = '_import.txt' -NPC_MASTER_IMPORTS = NPC_IMPORTS - -class State(object): - pass -State.INITIAL = State() -State.LAYER = State() -State.DATA = State() -State.FINAL = State() - -class Object(object): - __slots__ = ( - 'name', - #'map', - 'x', 'y', - 'w', 'h', - ) -class Mob(Object): - __slots__ = ( - 'monster_id', - 'max_beings', - 'ea_spawn', - 'ea_death', - ) + other_spawn_fields - def __init__(self): - self.max_beings = 1 - self.ea_spawn = 0 - self.ea_death = 0 - -class Warp(Object): - __slots__ = ( - 'dest_map', - 'dest_x', - 'dest_y', - ) + other_warp_fields - -class ContentHandler(xml.sax.ContentHandler): - __slots__ = ( - 'locator', # keeps track of location in document - 'out', # open file handle to .wlk - 'state', # state of collision info - 'tilesets', # first gid of each tileset - 'buffer', # characters within a section - 'encoding', # encoding of layer data - 'compression', # compression of layer data - 'width', # width of the collision layer - 'height', # height of the collision layer - 'base', # base name of current map - 'npc_dir', # world/map/npc/ - 'mobs', # open file to _mobs.txt - 'warps', # open file to _warps.txt - 'imports', # open file to _import.txt - 'name', # name property of the current map - 'object', # stores properties of the latest tag - 'mob_ids', # set of all mob types that spawn here - 'collision_fgid', # first gid in collision tileset - ) - def __init__(self, out, npc_dir, mobs, warps, imports): - xml.sax.ContentHandler.__init__(self) - self.locator = None - self.out = open(out, 'w') - self.state = State.INITIAL - self.tilesets = set([0]) # consider the null tile as its own tileset - self.buffer = bytearray() - self.encoding = None - self.compression = None - self.width = None - self.height = None - self.base = posixpath.basename(npc_dir) - self.npc_dir = npc_dir - self.mobs = mobs - self.warps = warps - self.imports = imports - self.object = None - self.mob_ids = set() - self.collision_fgid = 0 - - def setDocumentLocator(self, loc): - self.locator = loc - - # this method randomly cuts in the middle of a line; thus funky logic - def characters(self, s): - if not s.strip(): - return - if self.state is State.DATA: - self.buffer += s.encode('ascii') - - def startDocument(self): - pass - - def startElement(self, name, attr): - if dump_all: - attrs = ' '.join('%s="%s"' % (k,v) for k,v in attr.items()) - if attrs: - print('<%s %s>' % (name, attrs)) - else: - print('<%s>' % name) - - if self.state is State.INITIAL: - if name == u'property' and attr[u'name'].lower() == u'name': - self.name = attr[u'value'] - self.mobs.write('// %s\n' % MESSAGE) - self.mobs.write('// %s mobs\n\n' % self.name) - self.warps.write('// %s\n' % MESSAGE) - self.warps.write('// %s warps\n\n' % self.name) - - if name == u'tileset': - self.tilesets.add(int(attr[u'firstgid'])) - if attr.get(u'name','').lower().startswith(u'collision'): - self.collision_fgid = int(attr[u'firstgid']) - - if name == u'layer' and attr[u'name'].lower().startswith(u'collision'): - self.width = int(attr[u'width']) - self.height = int(attr[u'height']) - self.out.write(struct.pack(' 0: - self.out.write(chr(int(attr.get(u'gid',0)) - self.collision_fgid)) - else: - self.out.write(chr(0)) - elif self.state is State.FINAL: - if name == u'object': - if attr.get(u'type') == None: - return - obj_type = attr[u'type'].lower() - x = int(attr[u'x']) / TILESIZE; - y = int(attr[u'y']) / TILESIZE; - w = int(attr.get(u'width', 0)) / TILESIZE; - h = int(attr.get(u'height', 0)) / TILESIZE; - # I'm not sure exactly what the w/h shrinking is for, - # I just copied it out of the old converter. - # I know that the x += w/2 is to get centers, though. - if obj_type == 'spawn': - self.object = Mob() - if w > 1: - w -= 1 - if h > 1: - h -= 1 - x += w/2 - y += h/2 - elif obj_type == 'warp': - self.object = Warp() - x += w/2 - y += h/2 - w -= 2 - h -= 2 - else: - if obj_type not in other_object_types: - print('Unknown object type:', obj_type, file=sys.stderr) - self.object = None - return - obj = self.object - obj.x = x - obj.y = y - obj.w = w - obj.h = h - obj.name = attr[u'name'] - elif name == u'property': - obj = self.object - if obj is None: - return - key = attr[u'name'].lower() - value = attr[u'value'] - # Not true due to defaulting - #assert not hasattr(obj, key) - try: - value = int(value) - except ValueError: - pass - setattr(obj, key, value) - - def add_warp_line(self, line): - self.warps.write(line) - - def endElement(self, name): - if dump_all: - print('' % name) - - if name == u'object': - obj = self.object - if isinstance(obj, Mob): - if not hasattr(obj, u'max_beings') or not hasattr(obj, u'ea_spawn') or not hasattr(obj, u'ea_death'): - return - mob_id = obj.monster_id - if mob_id < 1000: - mob_id += 1002 - self.mob_ids.add(mob_id) - self.mobs.write( - SEPARATOR.join([ - '%s.gat,%d,%d,%d,%d' % (self.base, obj.x, obj.y, obj.w, obj.h), - 'monster', - obj.name, - '%d,%d,%d,%d,Mob%s::On%d\n' % (mob_id, obj.max_beings, obj.ea_spawn, obj.ea_death, self.base, mob_id), - ]) - ) - elif isinstance(obj, Warp): - if not hasattr(obj, u'dest_map') or not hasattr(obj, u'dest_x') or not hasattr(obj, u'dest_y'): - return - self.warps.write( - SEPARATOR.join([ - '%s.gat,%d,%d' % (self.base, obj.x, obj.y), - 'warp', - obj.name, - '%d,%d,%s.gat,%d,%d\n' % (obj.w, obj.h, obj.dest_map, obj.dest_x / 32, obj.dest_y / 32), - ]) - ) - - if name == u'data': - if self.state is State.DATA: - if self.encoding == u'csv': - for x in self.buffer.split(','): - if x <> 0: - self.out.write(chr(int(x) - self.collision_fgid)) - else: - self.out.write(chr(0)) - elif self.encoding == u'base64': - data = base64.b64decode(str(self.buffer)) - if self.compression == u'zlib': - data = zlib.decompress(data) - elif self.compression == u'gzip': - data = zlib.decompressobj().decompress('x\x9c' + data[10:-8]) - for i in range(self.width*self.height): - gid = int(struct.unpack(' 0: - self.out.write(chr(gid - self.collision_fgid)) - else: - self.out.write(chr(0)) - self.state = State.FINAL - - def endDocument(self): - self.mobs.write('\n\n%s.gat,0,0,0|script|Mob%s|-1,{\n' % (self.base, self.base)) - for mob_id in sorted(self.mob_ids): - self.mobs.write('On%d:\n set @mobID, %d;\n callfunc "MobPoints";\n end;\n\n' % (mob_id, mob_id)) - self.mobs.write(' end;\n}\n') - self.imports.write('// Map %s: %s\n' % (self.base, self.name)) - self.imports.write('// %s\n' % MESSAGE) - self.imports.write('map: %s.gat\n' % self.base) - - npcs = os.listdir(self.npc_dir) - npcs.sort() - for x in npcs: - if x == NPC_IMPORTS: - continue - if x.startswith('.'): - continue - if x.endswith('.txt'): - self.imports.write('npc: %s\n' % posixpath.join(SERVER_NPCS, self.base, x)) - pass - -def main(argv): - _, client_data, server_data = argv - tmx_dir = posixpath.join(client_data, CLIENT_MAPS) - wlk_dir = posixpath.join(server_data, SERVER_WLK) - npc_dir = posixpath.join(server_data, SERVER_NPCS) - - npc_master = [] - - for arg in os.listdir(tmx_dir): - base, ext = posixpath.splitext(arg) - - if ext == '.tmx': - tmx = posixpath.join(tmx_dir, arg) - wlk = posixpath.join(wlk_dir, base + '.wlk') - this_map_npc_dir = posixpath.join(npc_dir, base) - os.path.isdir(this_map_npc_dir) or os.mkdir(this_map_npc_dir) - print('Converting %s to %s' % (tmx, wlk)) - with open(posixpath.join(this_map_npc_dir, NPC_MOBS), 'w') as mobs: - with open(posixpath.join(this_map_npc_dir, NPC_WARPS), 'w') as warps: - with open(posixpath.join(this_map_npc_dir, NPC_IMPORTS), 'w') as imports: - xml.sax.parse(tmx, ContentHandler(wlk, this_map_npc_dir, mobs, warps, imports)) - npc_master.append('import: %s\n' % posixpath.join(SERVER_NPCS, base, NPC_IMPORTS)) - - with open(posixpath.join(npc_dir, NPC_MASTER_IMPORTS), 'w') as out: - out.write('// %s\n\n' % MESSAGE) - npc_master.sort() - for line in npc_master: - out.write(line) - -if __name__ == '__main__': - main(sys.argv) \ No newline at end of file -- cgit v1.2.3-70-g09d2