interpreted request from Carsten - make message sensor work.
authorCampbell Barton <ideasman42@gmail.com>
Fri, 3 Oct 2008 09:51:43 +0000 (09:51 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 3 Oct 2008 09:51:43 +0000 (09:51 +0000)
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

source/blender/blenkernel/BKE_blender.h
source/blender/blenloader/intern/readfile.c
source/blender/src/buttons_logic.c
source/gameengine/Converter/KX_ConvertActuators.cpp

index 0105587..421b430 100644 (file)
@@ -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
index 5b4fd47..25f9e17 100644 (file)
@@ -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! */
 
index a54f20b..5a8c731 100644 (file)
@@ -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: ",
index d5f304c..4f152ac 100644 (file)
@@ -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;