- Joined
- Dec 22, 2007
- Messages
- 184 (0.03/day)
- Location
- Central Nebraska
System Name | CORSAIR |
---|---|
Processor | AMD Phenom 1090T x6 @3.2 |
Motherboard | Gigabyte Ga-78LMT-S2P |
Cooling | High efficiency dust cooling |
Memory | 8GB GSkill DDR3 1333 |
Video Card(s) | Sapphire Radeon HD3870 512MB GDDR4 PCI-e toxic |
Storage | Seagate SV35.3 ST3250310SV 250GB SATAII(Windows 7 Pro x64), 320GB Samsung SATAII(Storage and SuSE) |
Display(s) | Dell 20" LCD, Dell 17" LCD |
Power Supply | Antec Cool Blue 650W Modular |
Software | Windows 7 Professional SP1, Visual Studio 2010 Ultimate |
I've been tryign to debug this for a week and have been unsuccessful finding the issue.
When runnign through the code below, the second function can never return the TargetID # from the database. I think there is something wrong with my input send to the function.
As I say - I think there is something with the input sent to the function, as the following line:
only ever returns "Target is <target>" and cuts the rest off afterwards.
making a gui version of this resulkts in the same thing.
The CharacterID (From function GrabCharacterID) is returned properly, but not the TargetID (from fucntion GrabTaretID, which is a copy/paste of GrabCharacterID). I think I have it narrowed down the the name I am sending to use to retrieve the ID. Somehow Im not stripping off a linefeed or carriage return or something properly.
Any ideas? I'm really at a loss here.
When runnign through the code below, the second function can never return the TargetID # from the database. I think there is something wrong with my input send to the function.
Code:
Function recv() As String
Dim data(4096) As Byte
sock.Receive(data, 4096, SocketFlags.None)
Dim mail As String = System.Text.ASCIIEncoding.UTF8.GetString(data)
Dim mailpeices As Array = mail.Split(" ")
If mail.Contains(" ") Then
If mail.Substring(0, 4) = "PING" Then
Dim pserv As String = mail.Substring(mail.IndexOf(":"), mail.Length - mail.IndexOf(":"))
pserv = pserv.TrimEnd(Chr(0))
mail = "PING from " & pserv & vbNewLine & "PONG to " & pserv
send("PONG " & pserv)
ElseIf mail.Contains("PRIVMSG") Then
Dim tmparr() As String = Nothing
Dim rnick As String
Dim rmsg As String
mail = mail.Remove(0, 1)
tmparr = mail.Split("!")
rnick = tmparr(0)
tmparr = mail.Split(":")
rmsg = tmparr(1)
mail = "msg: " & rnick & ">" & rmsg
'command identifier
If rmsg.StartsWith("!RXGB ") Then
' commands()
If rmsg.StartsWith("!RoXTELL join") Then
send("JOIN " & Channel)
ElseIf rmsg.StartsWith("!RXGB test2") Then
send("PRIVMSG " & Channel & " :I LIKE BREAD AND BUTTAAAAA!")
ElseIf rmsg.StartsWith("!RXGB test") Then
send("PRIVMSG " & rnick & " :Do you like Corn Syrup?")
End If
ElseIf rmsg.StartsWith("!RoXTELL join") Then
send("JOIN " & Channel)
End If
If rmsg.StartsWith("!RoXATTACK ") Then
Dim MessageParts() As String = rmsg.Split(Chr(32))
Dim MessageArray As Array = rmsg.Split(" ")
Dim Target As String = MessageParts(2) ' need proper case
Target = Target.Trim(" ")
Dim STAT_PLAYER_Attack As Integer
Dim STAT_TARGET_Defense As Integer
' Dim STAT_TARGET_HP As Integer
Select Case MessageParts(1).ToLower
Case "standard"
'grab PLAYER character ID
Dim CharacterID As Integer = GrabCharacterID(rnick)
Dim ReadStatPlayerAttackConnection As MySqlConnection = New MySqlConnection(mySQL_Server_String)
Dim ReadStatPlayerAttackString As String = "select Attack from Stats_" & rnick & " where ID = '" & CharacterID & "';"
Dim ReadStatPlayerAttackCommand As New MySqlCommand(ReadStatPlayerAttackString, ReadStatPlayerAttackConnection)
Dim ReadStatPlayerAttackReader As MySqlDataReader
Dim ReadStatPlayerAttackResult As Integer
Try
ReadStatPlayerAttackConnection.Open()
ReadStatPlayerAttackReader = ReadStatPlayerAttackCommand.ExecuteReader()
ReadStatPlayerAttackReader.Read()
ReadStatPlayerAttackResult = ReadStatPlayerAttackReader.GetInt16(0)
STAT_PLAYER_Attack = ReadStatPlayerAttackResult
cout.WriteLine(STAT_PLAYER_Attack)
ReadStatPlayerAttackReader.Close()
ReadStatPlayerAttackConnection.Close()
ReadStatPlayerAttackReader.Dispose()
ReadStatPlayerAttackConnection.Dispose()
'grab TARGET character ID
Dim TargetID As Integer = GrabTargetID(Target)
cout.WriteLine(Target & ":" & TargetID.ToString)
send("PRIVMSG " & Channel & " :Target is " & Target & ". Target ID is " & TargetID.ToString)
Try
Dim ReadStatTargetDefenseConnection As MySqlConnection = New MySqlConnection(mySQL_Server_String)
Dim ReadStatTargetDefenseString As String = "select Defense from Stats_" & Target & " where ID = '" & TargetID & "';"
Dim ReadStatTargetDefenseCommand As New MySqlCommand(ReadStatTargetDefenseString, ReadStatTargetDefenseConnection)
Dim ReadStatTargetDefenseReader As MySqlDataReader
Dim ReadStatTargetDefenseResult As Integer
ReadStatTargetDefenseConnection.Open()
ReadStatTargetDefenseReader = ReadStatTargetDefenseCommand.ExecuteReader()
ReadStatTargetDefenseReader.Read()
ReadStatTargetDefenseResult = ReadStatTargetDefenseReader.GetInt16(0)
STAT_TARGET_Defense = ReadStatTargetDefenseResult
cout.WriteLine(STAT_TARGET_Defense)
ReadStatTargetDefenseReader.Close()
ReadStatTargetDefenseConnection.Close()
ReadStatTargetDefenseReader.Dispose()
ReadStatTargetDefenseConnection.Dispose()
' Try
'
' Dim AttackDamage As Integer
' AttackDamage = STAT_PLAYER_Attack - STAT_TARGET_Defense
' Dim STAT_TARGET_NewHP As Integer
' STAT_TARGET_NewHP = STAT_TARGET_HP - AttackDamage
' Dim writeline As String = rnick & " attacks " & Target & " for " & AttackDamage.ToString & " points of damage."
' writeline = writeline.TrimEnd(Chr(0))
' writeline = writeline.Remove(writeline.LastIndexOf(vbLf), 1)
' writeline = writeline.Remove(writeline.LastIndexOf(vbCr), 1)
' cout.WriteLine(writeline)
' Catch
' Dim writeline As String = "Error calculating damage"
' writeline = writeline.TrimEnd(Chr(0))
' writeline = writeline.Remove(writeline.LastIndexOf(vbLf), 1)
' writeline = writeline.Remove(writeline.LastIndexOf(vbCr), 1)
' cout.WriteLine(writeline)
' End Try
Catch
Dim writeline As String = "Error grabbing target ID or Defense Stat"
cout.WriteLine(writeline)
End Try
Catch
Dim writeline As String = "Error grabbing player attack stat"
cout.WriteLine(writeline)
End Try
End Select
mail = ""
End If
ElseIf mail.Contains("IDENTIFY") Then
send("PRIVMSG nickserv :identify R@sM8V0Us")
ElseIf mail.Contains("recognized") Then
send("JOIN " & Channel)
ElseIf mail.Contains("JOIN") Then
If mailpeices(1) = "JOIN" Then
send("PRIVMSG " & Channel & " " & mailpeices(0) & " joined " & Channel & ".")
Else
End If
ElseIf mail.Contains(":") Then
End If
End If
Try
mail = mail.TrimEnd(Chr(0))
mail = mail.Remove(mail.LastIndexOf(vbLf), 1)
mail = mail.Remove(mail.LastIndexOf(vbCr), 1)
Return mail
Catch
End Try
End Function
Public Function GrabCharacterID(ByVal ProperName As String)
'Grab the newly created character's character # from the index
Dim GrabCharacterIDConnection As MySqlConnection = New MySqlConnection(mySQL_Server_String)
Dim GrabCharacterIDString As String = "select ID from Characters where Name = '" & ProperName & "';"
Dim GrabCharacterIDCommand As New MySqlCommand(GrabCharacterIDString, GrabCharacterIDConnection)
Dim GrabCharacterIDReader As MySqlDataReader
Dim Result As Integer = -1
Try
GrabCharacterIDConnection.Open()
GrabCharacterIDReader = GrabCharacterIDCommand.ExecuteReader()
GrabCharacterIDReader.Read()
Result = GrabCharacterIDReader.GetInt16(0)
Return Result
Catch e As Exception
Return Result
End Try
End Function
Public Function GrabTargetID(ByVal TargetName As String)
'Grab the newly created character's character # from the index
TargetName = TargetName.Trim(" ")
Dim GrabCharacterIDConnection As MySqlConnection = New MySqlConnection(mySQL_Server_String2)
Dim GrabCharacterIDString As String = "select ID from Characters where Name = '" & TargetName & "';"
Dim GrabCharacterIDCommand As New MySqlCommand(GrabCharacterIDString, GrabCharacterIDConnection)
Dim GrabCharacterIDReader As MySqlDataReader
Dim Result As Integer = -1
Try
GrabCharacterIDConnection.Open()
GrabCharacterIDReader = GrabCharacterIDCommand.ExecuteReader()
GrabCharacterIDReader.Read()
Result = GrabCharacterIDReader.GetInt16(0)
Return Result
Catch e As Exception
Return Result
End Try
End Function
As I say - I think there is something with the input sent to the function, as the following line:
Code:
send("PRIVMSG " & Channel & " :Target is " & Target & ". Target ID is " & TargetID.ToString)
making a gui version of this resulkts in the same thing.
The CharacterID (From function GrabCharacterID) is returned properly, but not the TargetID (from fucntion GrabTaretID, which is a copy/paste of GrabCharacterID). I think I have it narrowed down the the name I am sending to use to retrieve the ID. Somehow Im not stripping off a linefeed or carriage return or something properly.
Any ideas? I'm really at a loss here.
Last edited: