|
-
May 21st, 2006, 10:27 PM
#1
Thread Starter
Lively Member
Winsock byte arrays?
Hello, I have searched for awhile, and perhaps I might not know what to search for, but I cannot learn more about using byte arrays to send strings AND/OR UDTs using the same winsock control. Basically, I am making an online client/server game. I have gotten the chat to work, but the UDTs not so much. Ive used examples found on http://support.microsoft.com/defaul...b;EN-US;q152058 which works, but when I use my own UDT, it seems to overflow.
Here is my UDT:
VB Code:
Public Type location
X As Integer
Y As Integer
z As Integer
End Type
Public Type identity
account As String
password As String
name As String
gender As String
Class As String
subclass1 As String
subclass2 As String
subclass3 As String
age As Integer
race As String
level As Integer
exp As Integer
skillpts As Integer
statpts As Integer
talentpts As Integer
loc As location
End Type
Public Type wealth
notes As Integer
credits As Integer '100 notes = 1 credit
platinum As Integer '100 credits = 1 platinum
kesh As Integer '100 platinum = 1 kesh
lumber As Integer
food As Integer
ore As Integer
steel As Integer
iron As Integer
tin As Integer
stone As Integer
gold As Integer
bronze As Integer
copper As Integer
silver As Integer
End Type
Public Type stats
str As Integer
dex As Integer
int As Integer
vit As Integer
spi As Integer
ner As Integer 'nerve, depending on number, at low life can get intimidated or fight better
health As Integer
mana As Integer
rage As Integer 'when hit for certain amount, when missing, gain one rage; each point of rage increases miss rate by 5%, but increases damage by 3%
burnout As Integer 'tiredness, battle fatigue
hunger As Integer 'if 0, cant eat/drink
healthRegen As Double
manaRegen As Double
rageDegen As Double
End Type
Public Type combat
armor As Integer
armorReduc As Double
avgdmg As Double
dmgmod As Double
dodge As Double
crit As Double
block As Double
parry As Double
tohit As Double
spellhit As Double 'chance to hit on a spell
spelldmg As Double
End Type
Public Type resists
fire As Double
ice As Double
nature As Double
poison As Double
disease As Double
shadow As Double
holy As Double
magic As Double
End Type
'faction reputation from 0 to 10 (10 = best, 0 = worst)
Public Type rep
human As Double
elf As Double
orc As Double
ent As Double
undead As Double
centaur As Double
troll As Double
dwarf As Double
leithon As Double
betobian As Double
dragon As Double
yeti As Double
dryad As Double
goblin As Double
ogre As Double
roc As Double
satyr As Double
vampire As Double
titan As Double
sabre As Double
uriah As Double
razril As Double
jehkuk As Double
verjak As Double
bloodwind As Double
End Type
Public Type inventory
helm As item
shoulders As item
chest As item
back As item
belt As item
gloves As item
legs As item
boots As item
righthand As item
lefthand As item
ring1 As item
ring2 As item
neck1 As item
neck2 As item
trinket1 As item
trinket2 As item
trinket3 As item
backpack(40) As item
pocket(12) As item
pouch20(5) As item 'gained at level 20
pouch35(7) As item 'gained at level 35
pouch50(9) As item 'gained at level 50
pouch65(11) As item 'gained at level 65
pouch80(13) As item 'gained at level 80
pouch95(15) As item 'gained at level 95
End Type
'house/land/village variables for character
Global acres As Integer
Global armypower As Integer
Global taxrate As Double 'per turn, in credits
Global population As Double
Public Type hero
identity As identity
spellList As spellList
stats As stats
combat As combat
resists As resists
wealth As wealth
rep As rep 'reputation
inventory As inventory
End Type
Public myHero As hero
Quite hefty, I know, and it will get even larger as i add more things to the game. Reguardless, when it is saved directly to a text file, it is 18kb with a name filled out and the basic entries are put in. I'm not quite sure if it is too large, and it is causing it. I tried sending each sub-UDT (identity, spellList, stats, etc) and it still doesnt work. Anyone have any suggestions?
OK, moving on, assuming we get this to work, How do I do the array of bytes as a buffer? Ive seen examples and I truly dont get it; if you can point me to a tutorial, explain a bit, or give me the name of a good book I can buy, I'd much appreciate it.
Thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|