Skip to content

Commit

Permalink
Spanish language support, unicode fix
Browse files Browse the repository at this point in the history
Spanish language support, unicode fix
  • Loading branch information
olliz0r committed Nov 28, 2016
1 parent af3ebdd commit a297e8c
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 37 deletions.
13 changes: 13 additions & 0 deletions Ledybot/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Ledybot/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void btn_Start_Click(object sender, EventArgs e)
if (workerThread == null && workerObject == null)
{
workerObject = new Worker();
workerObject.setValues(tb_PokemonToFind.Text, tb_GiveAway.Text, tb_Default.Text, tb_Folder.Text, tb_Level.Text, tb_PID.Text);
workerObject.setValues(tb_PokemonToFind.Text, tb_GiveAway.Text, tb_Default.Text, tb_Folder.Text, tb_Level.Text, tb_PID.Text, cb_Spanish.Checked);
workerThread = new Thread(workerObject.DoWork);
workerThread.Start();
}
Expand Down
120 changes: 120 additions & 0 deletions Ledybot/Form1.resx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
3 changes: 3 additions & 0 deletions Ledybot/Ledybot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ScriptHelper.cs" />
<Compile Include="Worker.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Expand Down
49 changes: 21 additions & 28 deletions Ledybot/NTRClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,42 +137,35 @@ void handleReadMem(UInt32 seq, byte[] dataBuf)
return;
}
lastReadMemSeq = 0;
string fileName = lastReadMemFileName;
if (fileName != null)
{
FileStream fs = new FileStream(fileName, FileMode.Create);
fs.Write(dataBuf, 0, dataBuf.Length);
fs.Close();
//log("dump saved into " + fileName + " successfully");

int i = 0;
string szResult = "";
for (i = 0; i < dataBuf.Length; i++)
int i = 0;
int iBufferlength = dataBuf.Length;
for (i = 0; i < dataBuf.Length; i++)
{
if (i % 2 == 0)
{
if (i % 2 == 0)
if (dataBuf[i] == 0x00)
{
if (dataBuf[i] == 0x00)
{
break;
}
else
{
//this is what it looks like when you have no clue about unicode:
szResult = szResult + (char)dataBuf[i];
}
iBufferlength = i;
break;
}
}
}
byte[] actualBuffer = new byte[iBufferlength];
for(i = 0; i < actualBuffer.Length; i++)
{
actualBuffer[i] = dataBuf[i];
}

//string szResult = Encoding.Unicode.GetString(dataBuf);
string szResult = Encoding.Unicode.GetString(actualBuffer);

//t.BeginInvoke((MethodInvoker)delegate () { t.Text = szResult; ; });
lock (retValLock)
{
retVal = szResult;
retDone = true;
}
return;
//t.BeginInvoke((MethodInvoker)delegate () { t.Text = szResult; ; });
lock (retValLock)
{
retVal = szResult;
retDone = true;
}
return;
//log(byteToHex(dataBuf, 0));

}
Expand Down
63 changes: 55 additions & 8 deletions Ledybot/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@ namespace Ledybot
{
public class Worker
{
private uint addr_RequestedPokemon_en = 0x30784ef4;
private uint addr_RequestedPokemon_es = 0x307856F4;

private uint addr_RequestedLevel_en = 0x307879B4;
private uint addr_RequestedLevel_es = 0x307881B4;

private uint addr_DepositedPokemonNickname_en = 0x3077c514;
private uint addr_DepositedPokemonNickname_es = 0x3077cd14;

private uint addr_TrainerName_en = 0x305F1864;
private uint addr_TrainerName_es = 0x305F2064;

private uint addr_TrainerCountry_en = 0x305F2A14;
private uint addr_TrainerCountry_es = 0x305F3214;

private uint addr_TrainerSubCountry_en = 0x305F76A4;
private uint addr_TrainerSubCountry_es = 0x305F7EA4;

private uint addr_RequestedPokemon;
private uint addr_RequestedLevel;
private uint addr_DepositedPokemonNickname;
private uint addr_TrainerName;
private uint addr_TrainerCountry;
private uint addr_TrainerSubCountry;


private volatile string szPokemonToFind = "";
private volatile string szPokemonToGive = "";
Expand All @@ -20,6 +45,8 @@ public class Worker
private volatile string szLevel = "";
private volatile string szPID = "";
private volatile int iPID = 0;
private volatile bool bSpanish = false;

private volatile bool _shouldStop = false;
public void DoWork()
{
Expand Down Expand Up @@ -72,14 +99,14 @@ public void DoWork()

for(int i = 0; i < 25; i++)
{
string szReqPokemon = h.readSafe(0x30784ef4, 20, iPID);
string szReqPokemon = h.readSafe(addr_RequestedPokemon, 20, iPID);
if(szReqPokemon == this.szPokemonToGive)
{
string szLevel = h.readSafe(0x307879B4, 6, iPID);
string szLevel = h.readSafe(addr_RequestedLevel, 12, iPID);
szLevel = szLevel.ToLower();
if (szLevel.Contains(this.szLevel) || szLevel.Contains("any"))
if (szLevel.Contains(this.szLevel) || (!this.bSpanish && szLevel.Contains("any")) || (this.bSpanish && szLevel.Contains("cual")))
{
string szNickname = h.readSafe(0x3077c514, 20, iPID);
string szNickname = h.readSafe(addr_DepositedPokemonNickname, 20, iPID);

string szPath = this.szDefaultPk7;
string szFileToFind = this.szPk7Folder + szNickname + ".pk7";
Expand All @@ -93,9 +120,9 @@ public void DoWork()
string ek7 = BitConverter.ToString(cloneshort).Replace("-", ", 0x");

//optional: grab some trainer data
string szTrainerName = h.readSafe(0x305F1864, 20, iPID);
string szCountry = h.readSafe(0x305F2A14, 20, iPID);
string szSubCountry = h.readSafe(0x305F76A4, 20, iPID);
string szTrainerName = h.readSafe(addr_TrainerName, 20, iPID);
string szCountry = h.readSafe(addr_TrainerCountry, 20, iPID);
string szSubCountry = h.readSafe(addr_TrainerSubCountry, 20, iPID);

Program.f1.AppendListViewItem(szTrainerName, szNickname, szCountry, szSubCountry);
//Inject the Pokemon to box1slot1
Expand Down Expand Up @@ -146,15 +173,35 @@ public void RequestStop()
_shouldStop = true;
}

public void setValues(string szPtF, string szPtG, string szD, string szF, string szL, string szP)
public void setValues(string szPtF, string szPtG, string szD, string szF, string szL, string szP, bool bSpanish)
{
this.szPokemonToFind = szPtF;
this.szPokemonToGive = szPtG;
this.szDefaultPk7 = szD;
this.szPk7Folder = szF;
this.szLevel = szL;
this.szPID = szP;
this.bSpanish = bSpanish;


if (bSpanish)
{
addr_RequestedPokemon = addr_RequestedPokemon_es;
addr_RequestedLevel = addr_RequestedLevel_es;
addr_DepositedPokemonNickname = addr_DepositedPokemonNickname_es;
addr_TrainerName = addr_TrainerName_es;
addr_TrainerCountry = addr_TrainerCountry_es;
addr_TrainerSubCountry = addr_TrainerSubCountry_es;
}
else
{
addr_RequestedPokemon = addr_RequestedPokemon_en;
addr_RequestedLevel = addr_RequestedLevel_en;
addr_DepositedPokemonNickname = addr_DepositedPokemonNickname_en;
addr_TrainerName = addr_TrainerName_en;
addr_TrainerCountry = addr_TrainerCountry_en;
addr_TrainerSubCountry = addr_TrainerSubCountry_en;
}

this.iPID = int.Parse(szPID, NumberStyles.HexNumber);
}
Expand Down

0 comments on commit a297e8c

Please sign in to comment.