Navigation Menu

Skip to content

Commit

Permalink
* nativeguierror on mac using NSRunAlertPanel()
Browse files Browse the repository at this point in the history
* yatc_makedirs() for recursive making of directory
* on mac, we no longer use ~/.yatc/, now we use ~/Library/Application Support/OpenTibia/YATC/ according to apple recommendations
* added __DATE__ and __TIME__ support in some files to output compile date and time
* restored gmp support in addition to libtommath
* no longer able to enter random chars in optionsnetwork such as CRLF
* bumped date to 2010
* mac os x: project updated
  • Loading branch information
ivucica committed Jan 10, 2010
1 parent 7cece5b commit cceeada
Show file tree
Hide file tree
Showing 16 changed files with 1,690 additions and 58 deletions.
Binary file modified English.lproj/InfoPlist.strings
Binary file not shown.
2 changes: 1 addition & 1 deletion INSTALL
@@ -1,6 +1,6 @@
COMPILING YATC
==============
Copyright (C) 2007-2009 OpenTibia Team
Copyright (C) 2007-2010 OpenTibia Team

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
Expand Down
60 changes: 30 additions & 30 deletions Info.plist
@@ -1,30 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>yatc.icns</string>
<key>CFBundleDisplayName</key>
<string>YATC - Yet Another Tibia Client</string>
<key>CFBundleIdentifier</key>
<string>com.opentibia.yatc</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.2.4SVN</string>
<key>NSMainNibFile</key>
<string>SDLMain</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>yatc.icns</string>
<key>CFBundleDisplayName</key>
<string>YATC - Yet Another Tibia Client</string>
<key>CFBundleIdentifier</key>
<string>com.opentibia.yatc</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.3.2SVN</string>
<key>NSMainNibFile</key>
<string>SDLMain</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion README
@@ -1,6 +1,6 @@
YATC -- YET ANOTHER TIBIA CLIENT
================================
Copyright (C) 2007-2009 OpenTibia Team
Copyright (C) 2007-2010 OpenTibia Team

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
Expand Down
4 changes: 3 additions & 1 deletion gm_mainmenu.cpp
Expand Up @@ -339,10 +339,12 @@ void GM_MainMenu::pnlMainMenu_btnAbout_OnClick(glictPos* relmousepos, glictConta
GM_MainMenu* m = (GM_MainMenu*)g_game;
SDL_version sdl_compilever;
SDL_VERSION(&sdl_compilever);

txt << PRODUCTLONG << "\n"
<< PRODUCTVERSION << "\n"
<< gettext("Compiled on: ") << __DATE__ << " " << __TIME__ << "\n"
<< "\n"
<< c <<" 2007-2009 OpenTibia Team\n"
<< c <<" 2007-2010 OpenTibia Team\n"
<< "\n"
<< gettext("Current engine") << ": " << g_engine->getName() << "\n"
<< gettext("Uses SDL") << ": " << int(SDL_Linked_Version()->major) << "." << int(SDL_Linked_Version()->minor) << "." << int(SDL_Linked_Version()->patch) << " (" << gettext("compiled with") << ": " << int(sdl_compilever.major) <<"."<< int(sdl_compilever.minor) <<"."<< int(sdl_compilever.patch) << ")\n"
Expand Down
14 changes: 14 additions & 0 deletions macutil.h
@@ -0,0 +1,14 @@
#ifdef __cplusplus
extern "C" {
#endif

#ifndef MACUTIL_H
#define MACUTIL_H
#ifdef __APPLE__
int macutil_NSRunAlertPanel(const char* title, const char* text, const char *btn1, const char *btn2, const char *btn3,...);
#endif
#endif

#ifdef __cplusplus
}
#endif
12 changes: 12 additions & 0 deletions macutil.m
@@ -0,0 +1,12 @@
#include <Cocoa/Cocoa.h>
#include "macutil.h"
int macutil_NSRunAlertPanel(const char* title, const char* text, const char *btn1, const char *btn2, const char *btn3,...)
{
return
NSRunAlertPanel([NSString stringWithUTF8String:title],
[NSString stringWithUTF8String:text],
btn1 ? [NSString stringWithUTF8String:btn1] : nil,
btn2 ? [NSString stringWithUTF8String:btn2] : nil,
btn3 ? [NSString stringWithUTF8String:btn3] : nil
/*, args for a printf-style msg go here */);
}
1 change: 1 addition & 0 deletions main.cpp
Expand Up @@ -384,6 +384,7 @@ int main(int argc, char *argv[])
DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, PRODUCTLONG "\n");
DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "================================\n");
DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "version " PRODUCTVERSION "\n");
DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "compiled on " __DATE__ " " __TIME__ "\n");
#ifdef BUILDVERSION
DEBUGPRINT(DEBUGPRINT_LEVEL_OBLIGATORY, DEBUGPRINT_NORMAL, "build %s\n", BUILDVERSION);
#endif
Expand Down
33 changes: 29 additions & 4 deletions net/rsa.cpp
Expand Up @@ -26,18 +26,24 @@
#include "../debugprint.h"
RSA::RSA()
{
#ifdef HAVE_TOMMATH
#ifdef HAVE_TOMMATH
mp_init_size(&m_mod, 1024);
mp_init_size(&m_e, 1024);
#elif defined(HAVE_GMP_H)
mpz_init2(m_mod, 1024);
mpz_init2(m_e, 1024);
#endif
m_keyset = false;
}

RSA::~RSA()
{
#ifdef HAVE_TOMMATH
#ifdef HAVE_TOMMATH
mp_clear(&m_e);
mp_clear(&m_mod);
#elif defined(HAVE_GMP_H)
mpz_clear(m_e);
mpz_clear(m_mod);
#endif
}

Expand All @@ -47,8 +53,11 @@ void RSA::setPublicKey(const char* m, const char* e)
#ifdef HAVE_TOMMATH
mp_read_radix(&m_mod, m, 10);
mp_read_radix(&m_e, e, 10);
#elif defined(HAVE_GMP_H)
mpz_set_str(m_mod, m, 10);
mpz_set_str(m_e, e, 10);
#else
m_mod = m;
m_mod = m;
m_e = e;
#endif
}
Expand All @@ -73,14 +82,30 @@ bool RSA::encrypt(char* msg, int32_t size)

mp_clear(&c);
mp_clear(&plain);
#elif defined(HAVE_GMP_H)
mpz_t plain,c;
mpz_init2(plain, 1024);
mpz_init2(c, 1024);

mpz_import(plain, 128, 1, 1, 0, 0, msg);

mpz_powm(c, plain, m_e, m_mod);

size_t count = (mpz_sizeinbase(c, 2) + 7)/8;
memset(msg, 0, 128 - count);
mpz_export(&msg[128 - count], NULL, 1, 1, 0, 0, c);

mpz_clear(c);
mpz_clear(plain);

#else
BigInt plain(msg),c;

c = t_power(plain, m_e);
c = t_modulo(c, m_mod);

/* FIXME (ivucica#2#) we need to add bignum=>binary (meaning, convert from internal base into base 256) */
NativeGUIError("Please recompile with -lgmp and with #define HAVE_TOMMATH. Internal bignums are not done yet. Thank you!", "Bignums not done");
NativeGUIError("Please recompile with -ltommath and with #define HAVE_TOMMATH, or -lgmp and #define HAVE_GMP_H. Internal bignums are not done yet. Thank you!", "Bignums not done");
exit(EXIT_FAILURE);


Expand Down
10 changes: 9 additions & 1 deletion net/rsa.h
Expand Up @@ -26,6 +26,12 @@

#if HAVE_TOMMATH
#include <tommath.h>
#elif HAVE_GMP_H
#ifndef __APPLE__
#include <gmp.h>
#else
#include <GMP/gmp.h>
#endif
#else
#include "../bigint.h"
#endif
Expand All @@ -48,8 +54,10 @@ class RSA{

bool m_keyset;

#ifdef HAVE_TOMMATH
#ifdef HAVE_TOMMATH
mp_int m_mod, m_e;
#elif defined(HAVE_GMP_H)
mpz_t m_mod, m_e;
#else
BigInt m_mod, m_e;
#endif
Expand Down
23 changes: 17 additions & 6 deletions notifications.cpp
Expand Up @@ -25,8 +25,7 @@
#include "gm_gameworld.h"
extern Connection* g_connection;

std::list<std::string> g_recFiles;
std::list<std::string>::iterator g_recIt;
extern std::string g_recordfilename;

#include "gamecontent/container.h"
#include "gamecontent/shop.h"
Expand Down Expand Up @@ -122,13 +121,25 @@ void Notifications::onProtocolError(bool fatal)
else
s << "There was a protocol warning: " << error << std::endl;
s << std::endl;
s << "If you use GNU/Linux, please see your terminal for more information." << std::endl;
s << "If you use Windows, please see stdout.txt for more information." << std::endl;
#if !defined(WIN32) && !defined(__APPLE__)
s << "You use GNU/Linux version: please see your terminal for more information." << std::endl;
#endif
#if defined(WIN32)
s << "You use Windows version: please see stdout.txt for more information." << std::endl;
#endif
#if defined(__APPLE__)
s << "You use MacOSX: please see Console.app (in /Applications/Utilities) for more information." << std::endl;
#endif
s << std::endl;
s << "Report this bug if you are able to reproduce it." << std::endl;
s << "Tell us what we have to do to reproduce the bug, and provide us with" << std::endl;
s << "last 20 lines of stdout.txt, or the output on the terminal, depending" << std::endl;
s << "on your operating system." << std::endl;
s << "last 20 lines of output as described above." << std::endl;
s << std::endl;
s << "In your report please also include debug record file " << g_recordfilename << "." << std::endl;
s << "Note, this will include information which can be used to identify" << std::endl;
s << "your character, your VIP list, your full chat log for the session" << std::endl;
s << "(including private messages). It will not include username, password," << std::endl;
s << "or server name." << std::endl;
s << std::endl;
NativeGUIError(s.str().c_str(), "Protocol error");
}
Expand Down
9 changes: 9 additions & 0 deletions product.h
Expand Up @@ -24,4 +24,13 @@
#define PRODUCTLONG "YATC - Yet Another Tibia Client"
#define PRODUCTNAME PRODUCTSHORT " v" PRODUCTVERSION
#define PRODUCTLONGNAME PRODUCTLONG " version " PRODUCTVERSION


#if !defined(__DATE__)
#define __DATE__ "unknown"
#endif
#if !defined(__TIME__)
#define __TIME__ ""
#endif

#endif
13 changes: 9 additions & 4 deletions ui/login.h
Expand Up @@ -41,7 +41,8 @@ class winLogin_t {

glictButton btnOk, btnCancel;

winLogin_t() {
winLogin_t()
{

window.SetWidth(231-4);
window.SetHeight(173-17 - 2);
Expand Down Expand Up @@ -131,12 +132,16 @@ class winLogin_t {

}

void permitAccountName(bool yes) {
if(yes){
void permitAccountName(bool yes)
{
if(yes)
{
// we can't have weird-ass symbols in account names either. ;)
txtUsername.SetAllowedChars(" !\"#$%/()=?*'+<>[]{}`~\\|;:_,.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
pnlUsername.SetCaption(gettext("Account name:"));
} else {
}
else
{
txtUsername.SetAllowedChars("0123456789");
pnlUsername.SetCaption(gettext("Account number:"));
}
Expand Down
2 changes: 2 additions & 0 deletions ui/optionsnetwork.h
Expand Up @@ -83,6 +83,7 @@ class winOptionsNetwork_t {

window.AddObject(&txtServer);
txtServer.SetCaption("");
txtServer.SetAllowedChars(" !\"#$%/()=?*'+<>[]{}`~\\|;:_,.-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
txtServer.SetPos(16, 27);
txtServer.SetWidth(200);
txtServer.SetHeight(13);
Expand All @@ -99,6 +100,7 @@ class winOptionsNetwork_t {

window.AddObject(&txtPort);
txtPort.SetCaption("");
txtPort.SetAllowedChars("0123456789");
txtPort.SetPos(16, 60);
txtPort.SetWidth(200);
txtPort.SetHeight(13);
Expand Down

0 comments on commit cceeada

Please sign in to comment.