collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: New AOChat Class to handle FC's new "Encoding"  (Read 5102 times)

0 Members and 1 Guest are viewing this topic.

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« on: November 26, 2005, 12:20:01 pm »
UPDATED

Dunno how many saw that Auno released a new AOChat.php v1.18 but anyway I looked it over and since the new AOChat.php require PHP5 and alot of us are still running PHP4.x I still want to use the the new Class to parse FC's funktified coding.

So anyway after reading the notes Auno left about the class (class AOExtMsg) I copied that class(lines 970 - 1170 in v1.18)  into v1.17

You can get this Modified copy of AOChat.php for PHP4 Here.
Thank you Khalem for the tips. :)
In Bebot's Bot.php Find:
Code: [Select]
  function inc_gmsg($args)
    {
      $user = $this -> aoc -> get_uname($args[1]);

      $found = false;

      $group = $this -> aoc -> lookup_group($args[0]);

      $args[2] = utf8_decode($args[2]);
Replace with:
Code: [Select]
     function inc_gmsg($args)
    {
      $user = $this -> aoc -> get_uname($args[1]);

      $found = false;
     
      $group = $this -> aoc -> lookup_group($args[0]);

      if (!$group) $group = $this -> aoc -> get_gname($args[0]);

      if($user == "0" && (substr($args[2], 0, 2) == "~&"))
      {
         $a_aoext = new AOExtMsg($args[2]);
         $args[2] = $a_aoext -> text;
      }
      else
        $args[2] = utf8_decode($args[2]);

Notes: Towers module as it stands won't Parse the new returned text (See Post Below for explaination). City attacks parse fine. Buildings being removed and such aren't handled by the new AOExtMsg Class.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
New AOChat Class to handle FC's new "Encoding"
« Reply #1 on: November 26, 2005, 06:18:46 pm »
As for the change it was actually a good one, just inconvenient. They finally got around to doing what they should have done from day one, separate server output from language specific strings. This way they can now easilly make a German localized client without having to change the data in both client and server (at least its the start of it)

I havent had time to look into this as of yet. What spare time ive had ive spent ingame playing.

Im hoping to get some time to start looking into this tomorrow.
BeBot Founder and Fixer Kingpin

Offline Wanuarmi

  • Contributor
  • *******
  • Posts: 121
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #2 on: November 26, 2005, 09:48:57 pm »
urhm does that mean we all gonna need to install php5?

its not that bad, just install php5 and change the start.php to the new interpreter... I just hope installing it wont mess the other stuff that uses php4.

didnt know AOChat.php was from auno, does bebot always use an unmodified version of it?

wtb less work

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #3 on: November 26, 2005, 11:32:00 pm »
Yes Bebot has always used an unmodified version of AOChat.php. Most recently v1.17

I however just finished modifying version 1.17 to use the AO extended messages class that's in v1.18. I've named it v1.17.1 for my own peice of mind so I know it still work with PHP4.2.x
Note: I havn't tested the changes yet. When I do and it works I'll post a compatible Bebot/PHP4 version of aochat.php

As for PHP5, all the core files stay the same however there is one additional file that would need to be installed with the bot if your going to use aochat.php v1.18 and thats the PHP extension to handle the AO key exchange (AOKex). However that extention as far as I know has not been compiled into a DLL for Windows use. AOChat.php v1.18 looks for the AOKex extention on start up.

The above is the reason I chose to import the new Class into a prior version of aochat.php
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #4 on: November 27, 2005, 03:55:20 am »
Disreguard this post.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
New AOChat Class to handle FC's new "Encoding"
« Reply #5 on: November 27, 2005, 04:49:46 am »
P.S: Bebot 0.3.x uses a modified version of AOChat.php already.
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #6 on: November 27, 2005, 07:07:07 am »
Hmm the only Mod I could find in the one you have with 0.3.0 was already implemented in v1.17 and later. I.E. The change to lookup_user($u)

Also the version with 0.3.0 doesn't have the Flood and Priority stuff in it.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Izolenta

  • BeBot Rookie
  • *
  • Posts: 3
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #7 on: November 27, 2005, 09:29:12 am »
For supporting other languages than Latin ones, you just need to replace that dumb "utf8_encode/utf8_decode" functions for iconv function. Thats the simpliest solution imo

Offline Derroylo

  • Contributor
  • *******
  • Posts: 43
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #8 on: November 27, 2005, 06:15:19 pm »
Dunno where you guys have problem with php5 it is working fine for my bots :)

Anyway the code in the first post will not working 100% correctly since not every msg in that channel is in the new format. The msg about initiating attack and unguilded attackers are still a plain text and when you giving these msg to the ExtMsg Class from auno he will just give you an unknown extended message error back. Start to love FC :shock:
Derroylo 220/23 NT RK2

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
New AOChat Class to handle FC's new "Encoding"
« Reply #9 on: November 27, 2005, 10:16:15 pm »
I have this somewhat working right now. Trying to round up one remaining issue that i cant quite make sense out of.
Will update before i go to bed.
BeBot Founder and Fixer Kingpin

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
New AOChat Class to handle FC's new "Encoding"
« Reply #10 on: November 27, 2005, 10:42:29 pm »
Ok, use the AOChat.php provided in the first post.

in Bot.php find (make sure you are in the correct function):
Code: [Select]

   function inc_gmsg($args)
    {
      $user = $this -> aoc -> get_uname($args[1]);

      $found = false;

      $group = $this -> aoc -> lookup_group($args[0]);

      $args[2] = utf8_decode($args[2]);


Change to:
Code: [Select]

   function inc_gmsg($args)
    {
      $user = $this -> aoc -> get_uname($args[1]);

      $found = false;

      if($user == "0" && (substr($args[2], 0, 2) == "~&"))
      {
         $a_aoext = new AOExtMsg($args[2]);
         $args[2] = $a_aoext -> text;
      }
      else
        $group = $this -> aoc -> lookup_group($args[0]);


This is a bit of a kludge atm imho, but im not proficient enough in PHP to see any other way of doing this without changing how AOChat.php works.
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #11 on: November 27, 2005, 11:59:27 pm »
Actually that doesn't work so well. That method has the bot ignoring anything in Groups that have a user ID of 0.

Changed to this and it works like a champ:
Code: [Select]
  function inc_gmsg($args)
    {
      $user = $this -> aoc -> get_uname($args[1]);

      $found = false;
     
      $group = $this -> aoc -> lookup_group($args[0]);

      if($user == "0" && (substr($args[2], 0, 2) == "~&"))
      {
         $a_aoext = new AOExtMsg($args[2]);
         $args[2] = $a_aoext -> text;
      }
      else
        $args[2] = utf8_decode($args[2]);


P.S. The string returned via the new Class for Tower messages is a different format than what TowerAttack.php expects.
EX from log: [GROUP]   [MSG]   [All Towers] 0: Jigglez (OMNI, Area 41) attacked ***{ Adventurers Luck }*** (CLAN) at Tir County, 598x1282.
So a rewrite will be in order for TowerAttack.php to parse correctly. AlienAttack_GUILD.php OTH works great.

Oh and yes that's using the Modified AOChat.php I have linked to above.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Khalem

  • BeBot Founder
  • Administrator
  • ********
  • Posts: 1169
  • Karma: +0/-0
    • http://www.ancarim.com
New AOChat Class to handle FC's new "Encoding"
« Reply #12 on: November 28, 2005, 12:08:41 am »
Urgh, coding while sleeping(tm)

Thx.
BeBot Founder and Fixer Kingpin

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #13 on: November 28, 2005, 01:04:13 am »
Quote from: "Derroylo"
Dunno where you guys have problem with php5 it is working fine for my bots :)

Anyway the code in the first post will not working 100% correctly since not every msg in that channel is in the new format. The msg about initiating attack and unguilded attackers are still a plain text and when you giving these msg to the ExtMsg Class from auno he will just give you an unknown extended message error back. Start to love FC :shock:


Problem with PHP5 and new AOChat.php v1.18 is it requires the AOKex PHP extention(also written by Auno) to work. That extention is a Linux extention and hasn't been compiled for Windows users yet. So until I have AOKex.dll extention I'll be staying with PHP4. No interest in reslamming my Win2K File server to Linux just for a Bot.

As for the plain text messages and the new Class, it's being handled in the changes to Bebot's Bot.php I have posted above.
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

Offline Xenixa

  • Contributor
  • *******
  • Posts: 307
  • Karma: +0/-0
New AOChat Class to handle FC's new "Encoding"
« Reply #14 on: November 28, 2005, 03:30:05 am »
Fixed TowerAttack.php to parse the new string output to record in the DB correctly.

In TowerAttack.php Find:
Code: [Select]
      if (preg_match("/The (clan|neutral|omni) organization (.+) just entered a state of war!  (.+) attacked the (clan|neutral|omni) organization (.+)'s tower in (.+) at location \(([0-9]+), ([0-9]+)\)/i", $msg, $info))
        {
        $off_guild = $info[3];
        $off_side = $info[2];
        $off_player = $info[1];
        $def_guild = $info[4];
        $def_side = $info[5];
        $zone = $info[6];
        $x_coords = $info[7];
        $y_coords = $info[8];
        $attack = true;
        }
Replace With:
Code: [Select]
      if (preg_match("/(.+) \((CLAN|NEUTRAL|OMNI), (.+)\) attacked (.+) \((CLAN|NEUTRAL|OMNI)\) at (.+), ([0-9]+)x([0-9]+)/i", $msg, $info))
        {
        $off_player = $info[1];
        $off_side = ucfirst(strtolower($info[2]));
        $off_guild = $info[3];
        $def_guild = $info[4];
        $def_side = ucfirst(strtolower($info[5]));
        $zone = $info[6];
        $x_coords = $info[7];
        $y_coords = $info[8];
        $attack = true;
        }
« Last Edit: December 13, 2005, 12:59:35 am by Xenixa »
<<< Hack's in Zend Studio

All my Custom Bebot files may be Found Here <-clicky

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 269
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal