interpreted request from Carsten - make message sensor work.

object message actuators needed the prefix OB when sending a message to a specific object.--This line, and those below, will be ignored--

M    source/gameengine/Converter/KX_ConvertActuators.cpp
M    source/blender/blenkernel/BKE_blender.h
M    source/blender/src/buttons_logic.c
M    source/blender/blenloader/intern/readfile.c
This commit is contained in:
Campbell Barton 2008-10-03 09:51:43 +00:00
parent ae63fcc905
commit df00a4b878
4 changed files with 31 additions and 19 deletions

@ -41,7 +41,7 @@ struct ListBase;
struct MemFile;
#define BLENDER_VERSION 247
#define BLENDER_SUBVERSION 9
#define BLENDER_SUBVERSION 10
#define BLENDER_MINVERSION 245
#define BLENDER_MINSUBVERSION 15

@ -7926,9 +7926,27 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
la->sky_exposure= 1.0f;
}
}
/* BGE message actuators needed OB prefix, very confusing */
if (main->versionfile < 247 || (main->versionfile == 247 && main->subversionfile < 10)) {
bActuator *act;
Object *ob;
for(ob = main->object.first; ob; ob= ob->id.next) {
for(act= ob->actuators.first; act; act= act->next) {
if (act->type == ACT_MESSAGE) {
bMessageActuator *msgAct = (bMessageActuator *) act->data;
if (strlen(msgAct->toPropName) > 2) {
/* strip first 2 chars, would have only worked if these were OB anyway */
strncpy(msgAct->toPropName, msgAct->toPropName+2, sizeof(msgAct->toPropName));
} else {
msgAct->toPropName[0] = '\0';
}
}
}
}
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */

@ -2565,29 +2565,19 @@ static short draw_actuatorbuttons(Object *ob, bActuator *act, uiBlock *block, sh
case ACT_MESSAGE:
ma = act->data;
#define MESSAGE_SENSOR_TO_FIELD_WORKS /* Really? Not really. Don't remove this ifdef yet */
#ifdef MESSAGE_SENSOR_TO_FIELD_WORKS
ysize = 4 + (3 * 24); /* footer + number of lines * 24 pixels/line */
#else
ysize = 4 + (2 * 24); /* footer + number of lines * 24 pixels/line */
#endif
glRects(xco, yco-ysize, xco+width, yco);
uiEmboss((float)xco, (float)yco-ysize,
(float)xco+width, (float)yco, 1);
myline=1;
#ifdef MESSAGE_SENSOR_TO_FIELD_WORKS
/* line 1: To */
uiDefBut(block, TEX, 1, "To: ",
(xco+10), (yco-(myline++*24)), (width-20), 19,
&ma->toPropName, 0, 31, 0, 0,
"Optional send message to objects with this name only (Prefix name with OB)"
", or empty to broadcast");
#endif
"Optional send message to objects with this name only, or empty to broadcast");
/* line 2: Message Subject */
uiDefBut(block, TEX, 1, "Subject: ",

@ -291,15 +291,19 @@ void BL_ConvertActuators(char* maggiename,
STR_String toPropName = (msgAct->toPropName
? (char*) msgAct->toPropName
: "");
/**
* Get the Message Subject to send.
/* BGE Wants "OB" prefix */
if (toPropName != "")
toPropName = "OB" + toPropName;
/**
* Get the Message Subject to send.
*/
STR_String subject = (msgAct->subject
? (char*) msgAct->subject
: "");
/**
* Get the bodyType
/**
* Get the bodyType
*/
int bodyType = msgAct->bodyType;