• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Add fromCylinder and toCylinder OnMoveItem TFS 1.2

secondlife

Active Member
Joined
Aug 1, 2009
Messages
300
Reaction score
25
Hello,
I try add this commit in my source tfs 1.2:
https://github.com/otland/forgottenserver/commit/2cdbbcc58e551d4e06d46050fb94de7dfe6943e7

But when i compile, receive this errors:
In file included from /root/theforgottenserver/src/events.cpp:22:0:
/root/theforgottenserver/src/events.h:53:132: error: 'Cylinder' has not been declared
bool eventPlayerOnMoveItem(Player* player, Item* item, uint16_t count, const Position& fromPosition, const Position& toPosition, Cylinder* fromCylinder, Cylinder* toCylinder);
^
/root/theforgottenserver/src/events.h:53:156: error: 'Cylinder' has not been declared
bool eventPlayerOnMoveItem(Player* player, Item* item, uint16_t count, const Position& fromPosition, const Position& toPosition, Cylinder* fromCylinder, Cylinder* toCylinder);
^
/root/theforgottenserver/src/events.cpp:494:6: error: prototype for 'bool Events::eventPlayerOnMoveItem(Player*, Item*, uint16_t, const Position&, const Position&, Cylinder*, Cylinder*)' does not match any in class 'Events'
bool Events::eventPlayerOnMoveItem(Player* player, Item* item, uint16_t count, const Position& fromPosition, const Position& toPosition, Cylinder* fromCylinder, Cylinder* toCylinder)
^
In file included from /root/theforgottenserver/src/events.cpp:22:0:
/root/1507/src/events.h:53:8: error: candidate is: bool Events::eventPlayerOnMoveItem(Player*, Item*, uint16_t, const Position&, const Position&, int*, int*)
bool eventPlayerOnMoveItem(Player* player, Item* item, uint16_t count, const Position& fromPosition, const Position& toPosition, Cylinder* fromCylinder, Cylinder* toCylinder);
^
make[2]: *** [CMakeFiles/tfs.dir/src/events.cpp.o] Error 1
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
make: *** [all] Error 2


I need to add other functions in other files?? my source is little old (2-3 months ago) and i need add this function updated in my source revision.

Any idea?
Thank you!
 
Thx for the answers.
@Shyzoul, i think it is because my source is old (not very old). But this source is 1.2 version (approx 3 months ago).
@MatheusMkalo yes, i have luascript.h included in events.h
#include "luascript.h".

other ideas?
Thank you!
 
@secondlife the compiler output is that you wrote wrongly prototypes, probably you forget to add in your header file the new parameters to function, check there.
 
@Shyzoul I do not understand bro, this prototypes is another commit before this updated onMoveItem?
He said that you should check the declaration in the header file (events.h) and apply the changes. You probably forgot.

This
bool eventPlayerOnMoveItem(Player* player, Item* item, uint16_t count, const Position& fromPosition, const Position& toPosition);

To
bool eventPlayerOnMoveItem(Player* player, Item* item, uint16_t count, const Position& fromPosition, const Position& toPosition, Cylinder* fromCylinder, Cylinder* toCylinder);
 
@secondlife no a prototype of a function is a prototype as it says, you need this because all C/C++ programs start ever from a function called main(), so if you do this:
Code:
int main() {
a(1);
return 1;
}
int a(n) {
n = 10;
return n;
}
you will get compile error, because function a wasnt declared to compiler, since it becomes after main, to avoid this you can do a prototype which is in this case:
Code:
int a(n);

int main() {
a(1);
return 1;
}
int a(n) {
n = 10;
return n;
}
so the program has a prototype to it and when you call it knows what it is, in all tfs cases every function prototypes are inside the header files, (file that has .h extension) search in event.h and search for: Events::eventPlayerOnMoveItem and write the new parameters Cylinder* fromCylinder, Cylinder* toCylinder.
 
@MatheusMkalo @Shyzoul
i have added in luascript.h
class Cylinder;
and
static void pushCylinder(lua_State* L, Cylinder* cylinder);

Now it works!!
Other question, in revision of my source have:
if (Creature* parentCreature = parent->getCreature()) {
pushUserdata<Creature>(L, parentCreature);
setCreatureMetatable(L, -1, parentCreature);
} else if (Item* item = parent->getItem()) {
pushUserdata<Item>(L, item);
setItemMetatable(L, -1, item);
} else if (Tile* tile = parent->getTile()) {
pushUserdata<Tile>(L, tile);
setMetatable(L, -1, "Tile");
} else {
lua_pushnil(L);
}
return 1;
}
And in last revision only have:
pushCylinder(L, parent);
return 1;
}
This change is much important or i can stay with the old?? Im afraid of further problems, crash etc.
Thank you!!
 
@secondlife i think you fixed wrongly, anyway what you mean with revision? if y ou are asking what it does, since i dont know which function it is i assume it is crucial thing for pseudo oriented object for lua, it could broke all lua api.
 
@Shyzoul it works correctly. I needed it just for use this line in script OnMoveItem:
toPosition.x == CONTAINER_POSITION and toCylinder and toCylinder:getId() == 26052 then
And now this script works 100%.
Im afraid of crash etc
 
Back
Top