]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_execprogram.h
added -Wdeclaration-after-statement to warn about any use of C99 lazy variable declar...
[xonotic/darkplaces.git] / prvm_execprogram.h
index b9504c84e493a06c1c63b8bb9a826cd3d1ff8926..82f1a97a3c60793fe5d9627fd9a2163b8c1f3719 100644 (file)
                                OPC->vector[2] = OPB->_float * OPA->vector[2];
                                break;
                        case OP_DIV_F:
-                               OPC->_float = OPA->_float / OPB->_float;
+                               if( OPB->_float != 0.0f )
+                               {
+                                       OPC->_float = OPA->_float / OPB->_float;
+                               }
+                               else
+                               {
+                                       if( developer.integer >= 1 )
+                                       {
+                                               prog->xfunction->profile += (st - startst);
+                                               startst = st;
+                                               prog->xstatement = st - prog->statements;
+                                               VM_Warning( "Attempted division by zero in %s\n", PRVM_NAME );
+                                       }
+                                       OPC->_float = 0.0f;
+                               }
                                break;
                        case OP_BITAND:
                                OPC->_float = (int)OPA->_float & (int)OPB->_float;