SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Reply
 
Thread Tools Display Modes
Old 08/03/2013, 10:46 AM   #11
Mellnik
Gangsta
 
Mellnik's Avatar
 
Join Date: Dec 2011
Location: Paradise Falls, CAℕADA
Posts: 797
Reputation: 369
Default AW: Gamemode SDK for C/C++ (GDK)

Awesome!
Mellnik is offline   Reply With Quote
Old 08/03/2013, 10:48 AM   #12
steki.
High-roller
 
steki.'s Avatar
 
Join Date: Nov 2010
Location: São Paulo, Brasil
Posts: 2,576
Reputation: 315
Default Re: Gamemode SDK for C/C++ (GDK)

Quote:
Originally Posted by klklt0 View Post
Lack of knowledge?
Cmon, you should be joking with me

Just a noob don't know that having a gamemode based on a plugin it is still going to be on the same speed.
C/++ is a Impressive language, YES IT IS!, c++ is used here to give more functionality to pawn, not to write full gamemodes on it!
And you still say a Lack of knowledge?

A plugin to be executed will use more ram than the server function and script himself-
You still say a lack of knowledge?

This plugin can be runned without the .pwn script being created, but it still get's called BY THE SERVER to be executed, so it will be always more slower than the pawn script!
And you still say a lack of knowledge?

I am on a programming course for more than 1 year now, but since 4 years ago i script in c/++ based languages[php, java, javascript, c#, squirrel] as well on non c++ based languages[lua, python, delphin, pascal]
And you still say a lack of knowledge?

Just look for you, most likely you can't even declare a function in c/++ with OOP and Namespace.
And you still say a lack of knowledge?
I'm getting cancer with all your posts in this thread.
Think about this:
Pawn code is processed into opcodes which an abstract machine will process and convert it (or simply call, accordingly to the opcode and processor). That makes arithmetic and binary operations, flow control and native function calling possible and very easy to the scripter to develop an usable piece of code.

From the other side, let's think about an example: float.inc.
Will you dare to tell me a "locally" processor opcode complied dynamic library would be any slower than a pawn script on a script with only float and arithmetic functions?
If you think your high level libraries knowledge will, in some way, help you in this conversation about an opcode abstract machine and C++ std functions, you're fairly wrong.

Computers are all about the math. So, do your math! Literally.
steki. is offline   Reply With Quote
Old 08/03/2013, 10:48 AM   #13
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,521
Reputation: 2930
Default Re: Gamemode SDK for C/C++ (GDK)

klklt0: Have you actually read the source of this plugin at all? Or the source of the PAWN BVM (which is open-source)? If not, then I'd support the claim of "lack of knowledge" and add that you have an "abundance of speculation" - not the same thing at all.

Using your very basic logic they should be about the same speed - PAWN code is external to the server (because you write it not the team), so needs to be called by the server to run. This does exactly the same thing, but for C++ code - there is no difference. You are right that there may be a tiny bit more overhead involved in SOME calls (note the stress on "some"), but most of the code doesn't have that extra overhead and C++ is a much faster language in general than PAWN, think of it like an equation: 1% of your code is 10% slower, 99% is 10% faster - yes there are slower bits, but that's still a massive improvement over all.

By the way, serveral of your points were dangerously close to attacking the poster not the post - that is flaming and expressly against forum rules, debates are not.

Edit: To add to Stewie`'s point about float operations, this is how C++ compiles the code to add two floats together:

Code:
fld num1   ; load num1 and push it onto the fpu stack
fld num2   ; load num2 and push it onto the fpu stack
faddp      ; pop two numbers, add them, push sum on the stack
fstp res   ; pop sum from the stack and store it in res

Those are all native x87 instructions (x87 is the floating point unit in x86). Now here is just SOME of the code to do this in compiled PAWN:

Code:
// Push the parameters.
load.s.pri fffffff8
load.s.alt fffffffc
push.pri
push.alt
;$par
// Call the function.
push.c 8
sysreq.c 1	; operator+(Float:,Float:)
stack c
// Pop the result.
stor.s.pri fffffff4

Now the native function "floatadd" (+) looks something like this:

Code:
cell AMX_NATIVE_CALL n_floatadd(AMX * amx, cell * params)
{
    return amx_ftoc(amx_ctof(params[1]) + amx_ctof(params[2]));
}

And that hasn't even been compiled yet (it will be very similar to the original assembly I posted, but with more stuff around it).

Now, the final piece of this puzzle is the code that the VM runs to acually execute the various PAWN instructions like "push.pri" (from http://code.******.com/p/pawnscript/...nk/amx/amx.c):

Code:
    case OP_LOAD_S_PRI:
      GETPARAM(offs);
      pri=_R(data,frm+offs);
      break;
    case OP_LOAD_S_ALT:
      GETPARAM(offs);
      alt=_R(data,frm+offs);
      break;
    case OP_STOR_S:
      GETPARAM(offs);
      _W(data,frm+offs,pri);
      break;
    case OP_PUSH_PRI:
      PUSH(pri);
      break;
    case OP_PUSH_ALT:
      PUSH(alt);
      break;
    case OP_STACK:
      GETPARAM(offs);
      alt=stk;
      stk+=offs;
      CHKMARGIN();
      CHKSTACK();
      break;
    case OP_SYSREQ:
      GETPARAM(offs);
      /* save a few registers */
      amx->cip=(cell)((unsigned char *)cip-amx->code);
      amx->hea=hea;
      amx->frm=frm;
      amx->stk=stk;
      i=amx->callback(amx,offs,&pri,(cell *)(data+(int)stk));
      if (i!=AMX_ERR_NONE) {
        if (i==AMX_ERR_SLEEP) {
          amx->pri=pri;
          amx->alt=alt;
          amx->reset_stk=reset_stk;
          amx->reset_hea=reset_hea;
          return i;
        } /* if */
        ABORT(amx,i);
      } /* if */
      break;

And that's just SOME of the code involved - a lot of even what I posted is macros.

All this for:

Code:
c = a + b;
Y_Less is offline   Reply With Quote
Old 08/03/2013, 10:57 AM   #14
xeeZ
Huge Clucker
 
Join Date: Feb 2013
Posts: 316
Reputation: 380
Default Re: Gamemode SDK for C/C++ (GDK)

I'm not going to enumerate all of the advantages of C++ over the utter limited interpreted language and its VM designed to run in embedded systems with very limited resources. I'd just add that the little overhead involved in calling SA-MP natives or getting called back by the server that you might be concerned of is nothing compared to the speed of highly optimized native code you get with C/C++ (given that your server is not running on a toster).
xeeZ is offline   Reply With Quote
Old 08/03/2013, 11:18 AM   #15
GWMPT
High-roller
 
Join Date: Nov 2012
Location: Portugal.
Posts: 1,023
Reputation: 286
Default Re: Gamemode SDK for C/C++ (GDK)

Quote:
Originally Posted by Y_Less View Post
klklt0: Have you actually read the source of this plugin at all? Or the source of the PAWN BVM (which is open-source)? If not, then I'd support the claim of "lack of knowledge" and add that you have an "abundance of speculation" - not the same thing at all.
I've readed a bit of the GDK code, not all.
And the disadvantage was more considerated for the plugins on overall, and not for this plugin himself.
The little difference of this plugin to others is that it doesn't uses a .pwn script, but it still keeps getting called by the sa-mp server, the delay can exists or not, of course it depends on the code the function have, the calcules the server have to do, and so on, like you said.

But for other plugins, it is a bit slower because the Server needs to request to the PAWN SCRIPT which will request to the SERVER to execute the function X, which after executed will return the data to the SERVER, which will return to the PAWN function.

Since i don't know the sa-mp server architecture i can't neither say too much about it, nor how it does work internally.
So, since then it will have a little delay on the execution[even't if we don't notice it, there is a little delay].
It's like

Calls the function | executes the function | return the data
Server -> Pawn -> Server -> Plugin -> Server -> Pawn.

Quote:
Originally Posted by Y_Less View Post
By the way, serveral of your points were dangerously close to attacking the poster not the post - that is flaming and expressly against forum rules, debates are not.
I won't repeat it again, just make sure that he don't do the same.


@Stewie`
Are you perfect?
Because i'm not.
Failing and doing errors is a natural, no one is perfect, everyone fails, everyone do errors, and the most important, everyone learn with their errors.
GWMPT is offline   Reply With Quote
Old 08/03/2013, 11:20 AM   #16
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,521
Reputation: 2930
Default Re: Gamemode SDK for C/C++ (GDK)

But as you point out this plugin doesn't go through PAWN scripts, so why even bring the point up?
Y_Less is offline   Reply With Quote
Old 08/03/2013, 11:23 AM   #17
GWMPT
High-roller
 
Join Date: Nov 2012
Location: Portugal.
Posts: 1,023
Reputation: 286
Default Re: Gamemode SDK for C/C++ (GDK)

Quote:
Originally Posted by Y_Less View Post
But as you point out this plugin doesn't go through PAWN scripts, so why even bring the point up?
Nevermind it
GWMPT is offline   Reply With Quote
Old 08/03/2013, 12:07 PM   #18
steki.
High-roller
 
steki.'s Avatar
 
Join Date: Nov 2010
Location: São Paulo, Brasil
Posts: 2,576
Reputation: 315
Default Re: Gamemode SDK for C/C++ (GDK)

Quote:
Originally Posted by klklt0 View Post
Are you perfect?
Because i'm not.
Failing and doing errors is a natural, no one is perfect, everyone fails, everyone do errors, and the most important, everyone learn with their errors.
So there's your dilemma. I'm not perfect, but I try not to bullshit on something I don't know and also not to cause an indignation shitstorm like you did. You have to fill your chest and say: Please tell me where I'm wrong while I carefully read over all comments and try to aggregate as knowledge as possible! Yay.

Please don't get me wrong.
steki. is offline   Reply With Quote
Old 08/03/2013, 01:11 PM   #19
RajatPawar
High-roller
 
RajatPawar's Avatar
 
Join Date: Aug 2011
Location: ヽ༼ຈل͜ຈ༽ノ
Posts: 2,302
Reputation: 311
Default Re: Gamemode SDK for C/C++ (GDK)

Come on guys, chill out, we are kind of going off topic here. I would also like to congratulate xeeZ on this development, I find it quite useful and might post in here later about them, after ******-ing.

OFF-TOPIC: Also, klklt0, I suggest you try 'discussing' this over IRC with Y_Less, as it's almost impossible here to have a healthy discussion / debate with a moderator / beta tester without hundreds of 'loyal members' abusing you.
(No offense at any members)
RajatPawar is offline   Reply With Quote
Old 08/03/2013, 01:21 PM   #20
GWMPT
High-roller
 
Join Date: Nov 2012
Location: Portugal.
Posts: 1,023
Reputation: 286
Default Re: Gamemode SDK for C/C++ (GDK)

Quote:
Originally Posted by Stewie` View Post
So there's your dilemma. I'm not perfect, but I try not to bullshit on something I don't know and also not to cause an indignation shitstorm like you did. You have to fill your chest and say: Please tell me where I'm wrong while I carefully read over all comments and try to aggregate as knowledge as possible! Yay.

Please don't get me wrong.
I understand what you mean.


Quote:
Originally Posted by Rajat_Pawar View Post
Come on guys, chill out, we are kind of going off topic here. I would also like to congratulate xeeZ on this development, I find it quite useful and might post in here later about them, after ******-ing.

OFF-TOPIC: Also, klklt0, I suggest you try 'discussing' this over IRC with Y_Less, as it's almost impossible here to have a healthy discussion / debate with a moderator / beta tester without hundreds of 'loyal members' abusing you.
(No offense at any members)
I'm not a huge fan of IRC though xd
GWMPT is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Gamemode is unknown. When i connect theres no gamemode. Shannon_Brown Server Support 11 09/09/2012 09:49 AM
[GameMode] Brasil Drift Show [BDS] - Primeiro GameMode vitorzero3um Português/Portuguese 3 29/02/2012 07:48 PM
[ENG] Ideas for new GameMode [NL] Ideeen voor nieuwe Gamemode Xtreme-Nicole Everything and Nothing 10 10/07/2011 12:20 PM
[ENG] Ideas for new GameMode [NL] Ideeen voor nieuwe GameMode Xtreme-Nicole Help Archive 2 09/07/2011 12:24 PM


All times are GMT. The time now is 03:05 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.