Gamestudio Links
Zorro Links
Newest Posts
hello all
by jcl. 09/24/19 09:04
Right AssetsFix for trading Forex on IG?
by Andy60. 09/23/19 21:11
Converting fbx file to mdl7
by Dark_Light. 09/23/19 15:50
New system for Zorro S subscriptions
by jcl. 09/23/19 08:34
IG plugin initial release
by Andy60. 09/23/19 07:40
Any chance of PBR materials with A8?
by Dooley. 09/22/19 21:43
Levels, textures, etc for A8
by Dooley. 09/22/19 03:57
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
8 registered members (svenbob, Tamas, MatPed, Superku, kvm, jenGs, 3run, 1 invisible), 642 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Zylo, Hjuutgckk, Dark_Light, oxygenjoe, web20tpo
18292 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[ANet] Sending only an element of an array struct #445067
08/27/14 12:10
08/27/14 12:10
Joined: May 2008
Posts: 2,090
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,090
NRW/Germany
lets say i have a struct like this:
typedef struct {
var health;
var points;
...
}PLAYERSTRUCT;

And i declare and initialize it like this:
PLAYERSTRUCT Players[12];

Now i only want to send the health value of all 12 Players.
Do i need to do it in a for loop?

Or can i do something like this:
enet_sendto(Players.health,sizeof(var)*12,BROADCAST);


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [ANet] Sending only an element of an array struct [Re: alibaba] #445068
08/27/14 12:19
08/27/14 12:19
Joined: Apr 2007
Posts: 3,750
Canada
WretchedSid Offline
Expert
WretchedSid  Offline
Expert

Joined: Apr 2007
Posts: 3,750
Canada
Copy it into temporary buffer and send that buffer.


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com
Re: [ANet] Sending only an element of an array struct [Re: WretchedSid] #445069
08/27/14 12:29
08/27/14 12:29
Joined: May 2008
Posts: 2,090
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,090
NRW/Germany
The Problem is iŽm using the Memory Registration Mode, this means i have to register all datatypes at the beginning so i donŽt think i could register that temporary buffer at runtime.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [ANet] Sending only an element of an array struct [Re: alibaba] #445076
08/27/14 13:45
08/27/14 13:45
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Code:
for(int i = 0; i < 12; i++)
{
     pPlayer[i].points += 1;
     enet_sendto(&(pPlayer[i].points), sizeof(var), BROADCAST);
}



As simple as that laugh

Last edited by Ch40zzC0d3r; 08/27/14 13:46.
Re: [ANet] Sending only an element of an array struct [Re: Ch40zzC0d3r] #445077
08/27/14 14:06
08/27/14 14:06
Joined: May 2008
Posts: 2,090
NRW/Germany
alibaba Offline OP
Expert
alibaba  Offline OP
Expert

Joined: May 2008
Posts: 2,090
NRW/Germany
This is what i tried to avoid, because with every send call youŽll send 7 bytes of unnecessary data.
This is why i asked for a solution with only one send call.


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: [ANet] Sending only an element of an array struct [Re: alibaba] #445084
08/27/14 16:33
08/27/14 16:33
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
I guess if you dont want any unneeded overhead you need to write your own plugin :S
So if you really want to avoid that, you have to write an array for every element, such like:
Code:
int iScore[32];



Then your could will work for sure.
It cant work with a struct because the data is allocated in the same order, so you'd send the whole player array to achieve it.

Last edited by Ch40zzC0d3r; 08/27/14 16:39.
Re: [ANet] Sending only an element of an array struct [Re: Ch40zzC0d3r] #450225
04/09/15 22:52
04/09/15 22:52
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Don't get caught in the optimization trap.
If you're sending 7 unneeded bytes for 12 vars 15 times per second to 12 clients, you get unneeded 14 kbps. Is that really too much? And, if you update 5 times per second, which is enough for me, you get 4,5kbps...
My advice is, first, make your mechanics and features. Think about the optimization after that. laugh

My laptop uploads with 5 to 15 mbps to my country and at least 256kbps worldwide (Its usually in the 512kbps-2mbps range)...


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1